Example gallery — mayavi 4.6.2 documentation

# Example gallery

## Mlab functions gallery

These are the examples of the mlab plotting functions. They are copied out here for convenience. Please refer to the corresponding section of the user guide for more information ( 3D Plotting functions for numpy arrays).

`plot3d()` | `points3d()` | `imshow()`
`surf()` | `contour_surf()` | `mesh()`
`barchart()` | `triangular_mesh()` | `contour3d()`
`quiver3d()` | `flow()` |

## Advanced mlab examples

| Julia set example An example showing the Julia set displayed as a z-warped surface.
| Boy example A script to generate the Mayavi logo: a Boy surface.
| Bunny example Viewing Stanford 3D Scanning Repository bunny model
| Dragon example Viewing Stanford 3D Scanning Repository dragon model
| Lucy example Viewing Stanford 3D Scanning Repository lucy model
| Custom colormap example An example showing how a custom colormap (or look up table) can be used for a given object.
| Surface from irregular data example An example which shows how to plot a surface from data acquired irregularly.
| Spherical harmonics example Plot spherical harmonics on the surface of the sphere, as well as a 3D polar plot.
| Lorenz example An example displaying the trajectories for the Lorenz system of equations along with the z-nullcline.
| Canyon example Retrieve radar data from the NASA and plot a view of the Grand Canyon landscape.
| Julia set decimation example The Julia set, but with a decimated mesh: unecessary triangles due to the initial grid and not matching the geometry of the Julia set are removed.
| Simple structured grid example An example creating a structured grid data set from numpy arrays using TVTK and visualizing it using mlab.
| Atomic orbital example An example showing the norm and phase of an atomic orbital: isosurfaces of the norm, with colors displaying the phase.
| Tvtk in mayavi example An example of pure TVTK programming to build TVTK objects, which are then added to a Mayavi scene.
| Chemistry example In this example, we display the H2O molecule, and use volume rendering to display the electron localization function.
| Wigner example An example in which 3 functions of x and y are displayed with a surf plot, while the z scaling is kept constant, to allow comparison between them.
| Canyon decimation example Use the greedy-terrain-decimator to display a decimated terrain view.
| Plotting many lines example This examples shows how many lines can be grouped together in a single object, for convenience and efficiency.
| Magnetic field lines example This example uses the streamline module to display field lines of a magnetic dipole (a current loop).
| Mri example Viewing MRI data with cut plane and iso surface.
| Protein example Visualize a protein graph structure downloaded from the protein database in standard pdb format.
| Flight graph example An example showing a graph display between cities positionned on the Earth surface.

## Interactive examples

Examples showing how to use the interactive features of Mayavi, either via the mayavi2 application, or via specially-crafted dialogs and applications.

| Mlab visual example A very simple example to show how you can use TVTK’s visual module with mlab and create simple animations.
| Mlab traits ui example A simple example of how to use mayavi.mlab inside a traits UI dialog.
| Wx embedding example This example shows to embed a Mayavi view in a wx frame.
| Multiple engines example An example to show how you can have multiple engines in one application.
| Multiple mlab scene models example Example showing a dialog with multiple embedded scenes.
| Superquad with gui example This example uses MayaVi to show the evolution of a superquadric (http://en.w ikipedia.org/wiki/Superquadrics), which are ellipsoidal surfaces parametrised by two parameters,lpha and eta. The equations that are used to determine the superquadric are (in spherical-polar coordinates):
| Mlab interactive dialog example An example of how to modify the data visualized via an interactive dialog.
| Wx mayavi embed in notebook example This example show how to embedded Mayavi in a wx notebook.
| Subclassing mayavi application example This script demonstrates how one can script the Mayavi application by subclassing the application, create a new scene and create a few simple modules.
| Mayavi traits ui example An example of how to create a UI similar to the complete Mayavi application inside a Traits UI view.
| Compute in thread example This script demonstrates how one can do a computation in another thread and update the mayavi pipeline. It also shows how to create a numpy array data and visualize it as image data using a few modules.
| Qt embedding example This example demonstrates using Mayavi as a component of a large Qt application.
| Adjust cropping extents example A custom dialog to adjust the parameters of a GeometryFilter to crop data points.
| Poll file example A simple script that polls a data file for changes and then updates the mayavi pipeline automatically.
| Lorenz ui example This example displays the trajectories for the Lorenz system of equations using mlab along with the z-nullcline. It provides a simple UI where a user can change the parameters and the system of equations on the fly. This primarily demonstrates how one can build powerful tools with a UI using Traits and Mayavi.
| Volume slicer example Example of an elaborate dialog showing a multiple views on the same data, with 3 cuts synchronized.
| Coil design application example An full-blown application demoing a domain-specific usecase with Mayavi: interactive design of coils.
| Volume slicer advanced example An efficient implementation of the triple-plane view showing 3 cut planes on volumetric data, and side views showing each cut, with a cursor to move the other cuts.

## Advanced visualization examples

Data visualization using the core Mayavi API, object-oriented, and with more fine control than mlab.

- Polydata example

    An example of how to generate a polydata dataset using numpy arrays.

- Offscreen example

    A simple example of how you can use Mayavi without using Envisage or the Mayavi Envisage application and do off screen rendering.

- Surf regular mlab example

    Shows how to view data created by tvtk.tools.mlab with mayavi2.

- Glyph example

    This script demonstrates using the Mayavi core API to add a VectorCutPlane, split the pipeline using a MaskPoints filter and then view the filtered data with the Glyph module.

- Structured points2d example

    An example of how to generate a 2D structured points dataset using numpy arrays. Also shown is a way to visualize this data with the mayavi2 application.

- Contour contour example

    This example shows how you can produce contours on an IsoSurface.

- Scatter plot example

    An example of plotting scatter points with Mayavi’s core API.

- Streamline example

    This script demonstrates how one can script Mayavi’s core API to display streamlines and an iso surface.

- Numeric source example

    This script demonstrates how to create a numpy array data and visualize it as image data using a few modules.

- Structured points3d example

    An example of how to generate a 3D structured points dataset using numpy arrays. Also shown is a way to visualize this data with the mayavi2 application.

- Image cursor filter example

    Excample using the UserDefined filter to paint a cross-shaped cursor on data, in order to point out a special position.

- Contour example

    This script demonstrates how one can script Mayavi and use its contour related modules.

- Probe filter example

    Using the probe filter to visualize a scalar field along an arbitrary surface.

- Unstructured grid example

    A MayaVi example of how to generate an unstructured grid dataset using numpy arrays. Also shown is a way to visualize this data with mayavi2. The script can be run like so:

- Structured grid example

    An example of how to generate a structured grid dataset using numpy arrays. Also shown is a way to visualize this data with the mayavi2 application.

- Tvtk segmentation example

    Using VTK to assemble a pipeline for segmenting MRI images. This example shows how to insert well-controled custom VTK filters in Mayavi.

- Datasets example

    A Mayavi example to show the different data sets. See Data representation in Mayavi for a discussion.

- Delaunay graph example

    An example illustrating graph manipulation and display with Mayavi and NetworkX.

- Mlab 3D to 2D example

    A script to calculate the projection of 3D world coordinates to 2D display coordinates (pixel coordinates) for a given scene.

- Magnetic field example

    An example mixing numerical caculation and 3D visualization of the magnetic field created by an arbitrary number of current loops.

## Data interaction examples

Examples showing how you can query and interact with the data.

- Pick on surface example

    Example showing how to pick data on a surface, going all the way back to the index in the numpy arrays.

- Select red balls example

    This example shows how to use a callback to select a red ball amongst white balls.

## Misc examples

- Standalone example

    A simple example of how you can use Mayavi without using Envisage or the Mayavi Envisage application.

- Zzz reader example

    This is a simple example that shows how to create a reader factory and register that reader with mayavi.

- Nongui example

    This script demonstrates how one can use the Mayavi application framework without displaying Mayavi’s UI.

- User mayavi example

    Sample Mayavi customization file.