如何获得球体的坐标?

时间:2014-07-12 10:28:27

标签: python matplotlib 3d geometry

我想知道这个情节的所有坐标:

enter image description here

来源:http://matplotlib.org/examples/mplot3d/surface3d_demo2.html

enter image description here

来源:https://stackoverflow.com/a/11156353/3755171

并将其绘制为点球(仅考虑其中一个,我找不到那种):

enter image description here

或甚至矩阵都会这样做。

当我试图绘制上面提到的那些时,我得到了:

enter image description 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.plot(x,y,z,"o")

plt.show()

1 个答案:

答案 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()

Image