Reputation: 1
I am trying to visualize a 3D graph using Mayavi.
During the program run, some nodes or edges in the graph become unavailable and I want to visualize dynamically that they become inaccessible in the visualization scene. How can I achieve this?
I'm still a newbie in python but it seems that the Mayavi scene can't be changed through the program once it is displayed.
Upvotes: 0
Views: 715
Reputation: 13475
It can be changed in many ways. You can add and remove elements, change background and foreground colors, and animate stuff. For example (from this link):
from __future__ import absolute_import, division, print_function
from mayavi import mlab
import numpy as np
import math
alpha = np.linspace(0, 2*math.pi, 100)
xs = np.cos(alpha)
ys = np.sin(alpha)
zs = np.zeros_like(xs)
mlab.points3d(0,0,0)
plt = mlab.points3d(xs[:1], ys[:1], zs[:1])
@mlab.animate(delay=100)
def anim():
f = mlab.gcf()
while True:
for (x, y, z) in zip(xs, ys, zs):
print('Updating scene...')
plt.mlab_source.set(x=x, y=y, z=z)
yield
anim()
mlab.show()
, will return you an animation where two sphere exist and one is having it's position changed every step of time:
The Mayavi documentation isn't exactly brilliant from my point of view but you can get some information both from the examples and chapters. For example remove an object from Mayavi pipeline.
Upvotes: 1