[Matplotlib-devel] Need some help in 3D surface plotting...

vincent.adrien at gmail.com vincent.adrien at gmail.com
Mon Mar 12 12:17:01 EDT 2018


Hi Phani,

Please find attached a modified version of your script that should help 
(hopefully). It produces the attached PNG. I think that your problem is 
how to reshape your data before feeding them to the 3d plotting routine.

Besides, I am no mplot3d expert, but I wonder if there would be a way to 
set the z-axis on the left **without** relying on private attributes 
(this is often very **not** future-proof as such features can be changed 
without warning in a future version of the library).

Best,
Adrien

On 03/12/2018 06:19 AM, Phani Kumar wrote:
> Hi All,
> 
> I am trying to 3D surface plot the data from a .csv file. there is 
> already a reference plot drawn with this data (seems it was done by some 
> windows app) and I am trying to do the same with linux (in fact on 
> Raspberry Pi) with matplot library.
> 
> I have attached the .csv file for reference.
> 
> Original plot (with some microsoft tool) is as below.
> 
> and when I plot the same data with matplotlib, the plot is as below.
> 
> 
> Seems the plotting is ok, but for the layer of light orange patches - 
> not sure, what is causing this. My python code is as below. Let me know 
> if you have any suggestion for me.
> 
> from mpl_toolkits.mplot3d import Axes3D
> import matplotlib
> import matplotlib.pyplot as plt
> from matplotlib import cm
> from matplotlib.ticker import LinearLocator, FormatStrFormatter
> import numpy as np
> import csv
> 
> X = []
> Y = []
> Z = []
> 
> #Read the selected file
> with open ('Plasma.csv', 'r') as csvfile:
> plots = csv.reader (csvfile, delimiter=',')
> for row in plots:
> X.append(float(row[0]))
> Y.append(float(row[1]))
> Z.append(float(row[2]))
> 
> #Getting ready for the dispaly
> fig = plt.figure()
> ax = fig.gca(projection='3d')
> 
> #Set the labels...
> ax.set_xlabel('X (mm)')
> ax.set_ylabel('Y (mm)')
> ax.set_zlabel('CPD (mV)')
> 
> 
> 
> #Setting the places properly...
> tmp_planes = ax.zaxis._PLANES
> ax.zaxis._PLANES = (tmp_planes[2], tmp_planes[3],
> tmp_planes[0], tmp_planes[1],
> tmp_planes[4],tmp_planes[5])
> 
> # Make data.
> X, Y = np.meshgrid(X, Y)
> 
> #Plot
> surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm, linewidth=0)
> 
> plt.show()
> 
> 
> With best regards,
> Phani.
> 
> 
> _______________________________________________
> Matplotlib-devel mailing list
> Matplotlib-devel at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-devel
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.py
Type: text/x-python
Size: 1441 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-devel/attachments/20180312/8a4bff35/attachment-0001.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plasma.png
Type: image/png
Size: 92856 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-devel/attachments/20180312/8a4bff35/attachment-0001.png>


More information about the Matplotlib-devel mailing list