How can I plot surface on mplot3d for data like
(x,y,z)=(0,0,1),(0,0,2)......
I'm currently using mplot3d on python and I have a scatter data like
(x,y,z) = (0,1,3),(0,8,9),(1,5,24)......
I tried ax.scatter(xp,yp,zp)
, then scatter graph can be shown.
But when i try ax.plot_trisurf(xp,yp,zp)
for all the data, and plt.show()
then nothing appears on graph.
How can I plot surface graph from this data?
Any help would be appreciated, thanks.
As you currently have it, x = (0,1,3)
, y = (0,8,9)
and z=(1,5,24)
. I think you actually need to use zip
on your coordinates:
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
x,y,z = zip((0,1,3),(0,8,9),(1,5,24))
print x
# (0, 0, 1)
print y
# (1, 8, 5)
print z
# (3, 9, 24)
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot_trisurf(x, y, z, cmap=cm.jet, linewidth=0.2)
plt.show()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.