The MayaVi Data Visualizer is a fantastic visualization tool for scientific data. It's written in python and runs on top of VTK. More details on the web site.

This page is my small collection of tips and tricks harvested from the MayaVi users mailing list.

Hans Fangohr has posted a short comparison of MayVI and OpenDX.


Non-Interactive Rendering

This trick works on unix using the frame buffer X-server.
  1. Run Xvfb on an unused display (e.g. 9): Xvfb :9 -ac -screen 0 1024x1024x24
  2. Run python on that screen: DISPLAY=:9 ipython
Now you can run a python program, such as the following.
In [1]: import mayavi
In [2]: v = mayavi.mayavi ()
In [3]: v.load_visualization('cvs/mayavi/examples/')
In [4]: v.renwin.save_png('/tmp/test.png')   

Credit: Prabhu Ramachandran and Fernando Perez (see original thread).

Scalar legend in mayavi script

To add a scalar leged to a MayaVi visualization without using the GUI.
import mayavi
v = mayavi.mayavi ()
v.load_visualization ('examples/')

dvm = v.get_current_dvm()
mm = dvm.get_current_module_mgr ()
slh = mm.get_scalar_lut_handler ()

slh.legend_on_off ()
You can turn the legend off using
# turn off legend
slh.legend_on_off ()

Credit: Fernando Perez and Prabhu Ramachandran (can't find original thread in archive).


Parts of display vanish

    CF> Well, it sort of works on the debian machine, except that the
    CF> heart disappears after it is loaded, leaving just the grid and
    CF> axes. On the redhat machine, I still get the
    CF> ValueError.

Yes, the actor disappears from time to time due to a bug in Mesa.  I
believe Mesa 4.x should not have this problem.  Alternatively, if you
use an nVidia card then you will use their OpenGL libs which dont have
this bug.

 (1) To get around the problem for now click on the "configure data"
 button and click the re-read data option.  This should make verything

 (2) Use the unstable version of MEsa i.e. 3.4.2 or better still
 install xlibmesa instead of mesa.  This is a later version than
 testings Mesa and might make things a little more tolerable.

Credit: Prabhu Ramachandran (original thread).

Steve Robbins
Last modified: Thu Nov 7 20:39:52 EST 2002