Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Simple numpy reshape error wih contour3D
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:
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 ?
Larz60+ wrote Sep-17-2019, 12:45 PM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  numpy.copy / numpy.delete paul18fr 3 237 Jul-26-2019, 01:51 PM
Last Post: paul18fr
  Error installing numpy srm 3 484 Jul-08-2019, 06:26 PM
Last Post: srm
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 372 Apr-09-2019, 04:54 PM
Last Post: PhysChem
  'list' object has no attribute 'reshape' SamSoftwareLtd 1 3,302 Nov-04-2018, 10:38 PM
Last Post: stullis
  Newbie at using python and tensorflow getting error when running simple code FeatherineAu 0 1,621 Sep-28-2018, 02:09 PM
Last Post: FeatherineAu
  Simple Series Keyword Error Kris 4 1,640 Jan-22-2017, 08:16 PM
Last Post: micseydel

Forum Jump:

Users browsing this thread: 1 Guest(s)