我尝试使用mayavi为许多节点设置动画。现在我想根据它们的接近程度在节点之间包含链接,并在动画中说明这一点,但它不起作用。如果我使用x_pos而不是x_neigh,我会在节点之间看到一些链接,但是我想控制要显示的链接。有人可以帮忙吗?
plt = mlab.points3d(x_pos, y_pos, z_pos, resolution=5, scale_factor=8)
plt2 = mlab.plot3d(x_neigh, y_neigh, z_neigh, tube_radius=None)
msplt = plt.mlab_source
msplt2 = plt2.mlab_source
@mlab.animate(delay=100,ui=False)
def anim():
while True:
# Build nodes list
x_pos = np.array([(swarm[i].x_pos) for i in range(SIZE)])
y_pos = np.array([(swarm[i].y_pos) for i in range(SIZE)])
z_pos = np.array([(swarm[i].z_pos) for i in range(SIZE)])
# Build links list
x_neigh, y_neigh, z_neigh = create_geometric_random_graph(x_pos,y_pos,z_pos)
msplt.set(x=x_pos, y=y_pos, z=z_pos)
msplt2.set(x=x_neigh, y=y_neigh, z=z_neigh)
yield
anim()
mlab.show()