Reputation: 549
I am displaying a 3D volume with Mayavi and trying to add some modules to help visualize the dimension of the object. I intended to add a gridplane object but couldn't find out how. I tried the following :
from mayavi import mlab
from mayavi.modules.api import GridPlane
import numpy as np
scf = mlab.pipeline.scalar_field(np.load("volume.3d.npy"))
volume = mlab.pipeline.volume(scf)
gp = GridPlane()
gp.grid_plane.axis="x"
mlab.add_module(gp)
mlab.text(0, 0, "My volume")
mlab.show()
I get no error, but no gridplane is added to the visualization. I also tried :
scf = mlab.pipeline.scalar_field(np.load("volume.3d.npy"))
gp = mlab.pipeline.CustomGridPlaneFactory(scf.mlab_source)
volume = mlab.pipeline.volume(scf)
mlab.text(0, 0, "My volume")
mlab.show()
But nothing shows up as well. I feel like the second method should be the way to go because I am using the mlab.pipeline
call, but I am unable to tell why it doesn't show anything. Also, I think it is possible to do it because I can simply go to the scene parameters once mlab.show()
is called, and add a module manually (and GridPlane is one of the proposed modules), but I am unable to do it the same way I used to add text on the scene (see mlab.text
calls above). So I am wondering how it should be done.
Upvotes: 1
Views: 157