Reputation: 33
I know usually we use:
plot_surface(X, Y, Z)
where X
, Y
are 1-D array and Z
a matrix of dimension len(X)
× len(Y)
, to plot a surface.
But I now have only three columns of 1-D array as data. In other words, I have something like:
X=[1,2,3,4,5]
Y=[1,2,3,4,5]
and
Z=f(X,Y)=[1,2,3,4,5]
I do not have the expression of f
, but I want to plot a surface diagram nevertheless. How should I do it?
Please feel free to ask me to clarify my question. This is my first time asking questions on the platform.
Thank you in advance!
Upvotes: 3
Views: 3195
Reputation: 126
is this what you mean?:
import numpy as np
import matplotlib.pyplot as plt
x=[1,2,3,4,5]
y=[1,2,3,4,5]
z=np.array([[1],[2],[3],[4],[5]])
ax = plt.axes(projection='3d')
ax.plot_surface(x, y, z,cmap='viridis')
plt.show()
Upvotes: 1