In [5]:
%matplotlib qt
import numpy as np
from mayavi import mlab

Overview

Mayavi is a high level plotting library built on tvtk.

Mayavi has a uses mlab for it's higher level plotting functions. The list of plotting functions can be found here. Functions exist for ploting lines, surfaces, 3d contours, points, ect.

Most of the plot types have a built in example found at mlab.test_*


In [6]:
# try one example, figure is created by default
mlab.test_molecule()


Out[6]:
(<mayavi.modules.glyph.Glyph at 0x126fc0d70>,
 <mayavi.modules.glyph.Glyph at 0x126fca650>,
 <mayavi.modules.glyph.Glyph at 0x127ab8890>,
 <mayavi.modules.glyph.Glyph at 0x127a74ad0>)

Mayavi has some very useful interactive controls that can be accessed from the GUI. This includes the ability to record changing of parameters.


In [7]:
# clear the figure then load another example
mlab.clf()
mlab.test_flow_anim()


Out[7]:
<mayavi.tools.animator.Animator at 0x126fd2ad0>

In [9]:
# create a new figure
mlab.figure('mesh_example', bgcolor=(0,0,0,))
mlab.test_surf()


Out[9]:
<mayavi.modules.surface.Surface at 0x127e7ecb0>