Python Forum

Full Version: Simple numpy reshape error wih contour3D
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I create X and Y with
X = np.arange(0,34, 1)
Y = np.arange(0,22, 1) 
X,Y = np.meshgrid(X,Y)
ie X goes from 0..33 and Y goes from 0.21

My Z values are in a list and go like this X0Y0val, X0Y1val,...X0Y1val, X1Y0val,....,X33Y21val
I reshape these to get 2d array that matches X and Y above
Z = np.reshape(zline, [34, 22], 'C')
but when I use it in my contour3D call:
myplot = ax.contour3D(X, Y, Z, 50, cmap=cm.coolwarm, linewidth=0, antialiased=False)
I get this error:
Error:
TypeError: Shape of x does not match that of z: found (22, 34) instead of (34, 22).
Changing the reshapoe call to have [22,34] fixes the error but seems illogical.
What is the problem ?