Python Forum
Simple numpy reshape error wih contour3D
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple numpy reshape error wih contour3D
#1
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 ?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] How to store different data type in one numpy array? water 7 303 Mar-26-2024, 02:18 PM
Last Post: snippsat
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 2,530 Jul-19-2022, 06:31 AM
Last Post: paul18fr
  Issues with Shape/Reshape for CNN moddy10 0 1,429 Oct-12-2021, 03:54 PM
Last Post: moddy10
  [pandas] How to reshape the list Mekala 6 7,261 Jul-26-2020, 12:49 AM
Last Post: Mekala
  cannot reshape array of size 0 into shape Roro 2 6,196 Jun-14-2020, 11:28 AM
Last Post: Roro
  reshape from 3D to 3D matrix paul18fr 0 1,718 Nov-12-2019, 11:26 AM
Last Post: paul18fr
  Error installing numpy srm 3 3,472 Jul-08-2019, 06:26 PM
Last Post: srm
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 2,934 Apr-09-2019, 04:54 PM
Last Post: PhysChem
  'list' object has no attribute 'reshape' SamSoftwareLtd 1 15,486 Nov-04-2018, 10:38 PM
Last Post: stullis
  Newbie at using python and tensorflow getting error when running simple code FeatherineAu 0 3,966 Sep-28-2018, 02:09 PM
Last Post: FeatherineAu

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020