我正在尝试绘制一个简单的3D多面体并尝试用坐标标记顶点。我想做的第一步是简单地用每个顶点标记它们的顺序或1
,2
,...
我在this回答中看到我可以使用循环来执行此操作。但我想知道是否有可能传递x,y,z坐标列表和标签列表,它将简单地绘制点并标记它,可能没有任何循环。如果存在我不知道的功能。
这就是我现在所拥有的
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
#coord = 10*np.random.rand(3,num)#num points in 3D #first axis is x, second = y, third = z
xcod = np.array([1,2,3,2.7,2.4,1])
ycod = np.array([1,1,4,5.,6,1])
zcod = np.array([1,2,1,2,3,1])
#coord = np.concatenate(coord,coord[0])
#####plotting in 3d
fig = plt.figure()
ax = fig.add_subplot(111,projection = '3d')
#plotting all the points
ax.plot(xcod,ycod,zcod,'x-')
#adding labels for vertice
#ax.text(xcod,ycod,zcod,["1","2","3","4","5","6","7"])
#supposed centroid
ax.scatter(np.mean(xcod),np.mean(ycod),np.mean(zcod),marker = 'o',color='g')
ax.set_xlabel("x axis")
ax.set_ylabel("y axis")
ax.set_zlabel("z axis")
plt.show()
我尝试使用ax.text(xcod,ycod,zcod,["1","2","3","4","5","6"])
无效。我可以按照循环,但有另一种简单的方法吗?