1

I have a (2640, 96, 17) array. I am able to plot it by scatter plot but I would like to see the whole shape of this array, so I think the surface plot or contour will be better. But I cannot deal with z must be 2D array. z.ndim shows 2. I don't know what is going on. Or anyone could provide a new method for me, I will be highly appreciated.

x = np.arange(Outfinal_add.shape[0])[:, None, None]
y = np.arange(Outfinal_add.shape[1])[None, 30:60, None]
x, y= np.broadcast_arrays(x, y)
Z = np.zeros((Outfinal_add.shape[1],Outfinal_add.shape[2]))
Z = Outfinal_add[1][:]
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.contourf(x.ravel(),
           y.ravel(),
           Z.ravel())

Outfinal_add is the original data array (2640,96,17).

Zephyr
  • 11,891
  • 53
  • 45
  • 80
  • 1
    Can you provide dummy data or `Outfinal_add` to replicate the results. – Furqan Hashim Jul 08 '20 at 05:53
  • Does [this answer help](https://stackoverflow.com/a/18764960/565489) ? – Asmus Jul 08 '20 at 06:17
  • @Asmus I think that answer has the initial that x,y,z are 1D array. That is the part I am stuck with. The thing I only have is a 3_D array which is extracted from .mat file. I don't know how to change it into 1D array. – CorneliaW222 Jul 08 '20 at 18:50
  • @Furqan Hashim I tried np.random.rand(3,3,5). '''dummy = np.random.rand(3,3,5) // X1 = np.arange(dummy.shape[0])[:, None, None]// Y1 = np.arange(dummy.shape[1])[None, :, None]// X,Y= np.broadcast_arrays(X1, Y1) // Z = np.zeros((dummy.shape[1],dummy.shape[2]))// Z = dummy[1][:]// fig = plt.figure()// ax = fig.gca(projection='3d')// ax.contourf(x.ravel(), y.ravel(), Z.ravel())''' – CorneliaW222 Jul 08 '20 at 18:50
  • 1
    How do you expect to plot a 3D array in 3D? – Mad Physicist Jul 09 '20 at 17:41

0 Answers0