Creating data for Mayavi

This section of the user guide will be improved later. For now, the following two presentations best describe how one can create data objects or data files for Mayavi and TVTK.

There are several examples in the mayavi sources that highlight the creation of the most important datasets from numpy arrays. These may be found in the examples directory. Specifically they are:

  • polydata.py: Demonstrates how to create Polydata datasets from numpy arrays and visualize them in mayavi.
  • structured_points2d.py: Demonstrates how to create a 2D structured points (or image data) dataset from numpy arrays and visualize them in mayavi. This is basically a square of equispaced points.
  • structured_points3d.py: Demonstrates how to create a 3D structured points (or image data) dataset from numpy arrays and visualize them in mayavi. This is a cube of points that are regularly spaced.
  • structured_grid.py: Demonstrates the creation and visualization of a 3D structured grid.
  • unstructured_grid.py: Demonstrates the creation and visualization of an unstructured grid.

These scripts may be run like so:

$ mayavi2 -x structured_grid.py

or better yet, all in one go like so:

$ mayavi2 -x polydata.py -x structured_points2d.py \
> -x structured_points3d.py -x structured_grid.py -x unstructured_grid.py

Previous topic

Advanced Scripting with Mayavi

Next topic

Tips and Tricks

This Page

Quick search