我想知道这个情节的所有坐标:
来源:http://matplotlib.org/examples/mplot3d/surface3d_demo2.html
来源:https://stackoverflow.com/a/11156353/3755171
并将其绘制为点球(仅考虑其中一个,我找不到那种):
当我试图绘制上面提到的那些时,我得到了:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
#ax = fig.add_subplot(111, projection='3d')
ax = Axes3D(fig)
u, v = np.mgrid[0:2*np.pi:20j, 0:np.pi:10j]
x=np.cos(u)*np.sin(v)
y=np.sin(u)*np.sin(v)
z=np.cos(v)
#ax.plot_wireframe(x, y, z, color="r")
#ax.plot_surface(x, y, z, rstride=4, cstride=4, color='b')
ax.plot(x,y,z,"o")
plt.show()
答案 0 :(得分:1)
如果您将plot
的号码替换为scatter
,如下所示,则您将重新创建一个完全由点组成的球体。请参阅文档here。
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
#ax = fig.add_subplot(111, projection='3d')
ax = Axes3D(fig)
u, v = np.mgrid[0:2*np.pi:20j, 0:np.pi:10j]
x=np.cos(u)*np.sin(v)
y=np.sin(u)*np.sin(v)
z=np.cos(v)
#ax.plot_wireframe(x, y, z, color="r")
#ax.plot_surface(x, y, z, rstride=4, cstride=4, color='b')
ax.scatter(x,y,z,"o")
plt.show()