I am currently able to plot a pcolor style plot from some data. The data consists of three coordinates per data point (X,Y,Z).
My data is structured in the following way:
X: 1D array
shape = [500,0]
Y: 1D array
shape = [700,0]
Z: 2D array
shape = [500, 700]
So the rows of my Z array correspond to the X coordinate, and my columns correspond to the Y coordinate.
Then to plot the data on a pcolor plot, I simply did:
plt.pcolormesh(X,Y,Z.T)
The transpose is needed because of how pcolormesh expects to receive the input data.
Now I want to plot the same data as a surface using plot_surface. I am having issues, however, in structuring my data the necessary way. Can anyone offer any guidance?
plot_surfaceexpects all the inputs arrays to be 2D.You can use numpy.meshgrid to generate the grid points
You can then call
plot_surface(xx, yy, Z.T)