3D Python Graphics

Asked

Viewed 436 times

0

I have 3 arrays, from the arrays I must draw a 3D graphic. I have tried several ways but I could not. I believe I am not creating the data frames correctly. I’m trying to do it this way:

x = np.array(x_values)
y = np.array(y_values)

X, Y = np.meshgrid(x, y)
Z = np.array(z_values)

ax = plt.axes(projection='3d')
ax.plot_surface(X, Y, Z, rstride=1, cstride=1,cmap='viridis',edgecolor='none')

plt.show()

The code is returning the following error:

Valueerror: Argument Z must be 2-dimensional.

  • Argument Z must have two dimensions and in the case you put your Z only has one dimension. Take a look at the example on this site: https://matplotlib.org/3.1.1/gallery/mplot3d/surface3d.html

1 answer

-2

Z has to be a function that depends on X and Y. Ex: np.sin(x)*np.sin(y)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.