Key updates include: Jupyter notebook integration, movie recording capabilities, time series animation, updated VTK compatibility, and Python 3 support
by Prabhu Ramachandran, core developer of Mayavi and director, Enthought India
The Mayavi development team is pleased to announce Mayavi 4.5.0, which is an important release both for new features and core functionality updates.
Mayavi is a general purpose, cross-platform Python package for interactive 2-D and 3-D scientific data visualization. Mayavi integrates seamlessly with NumPy (fast numeric computation library for Python) and provides a convenient Pythonic wrapper for the powerful VTK (Visualization Toolkit) library. Mayavi provides a standalone UI to help visualize data, and is easy to extend and embed in your own dialogs and UIs. For full information, please see the Mayavi documentation.
Mayavi is part of the Enthought Tool Suite of open source application development packages and is available to install through Enthought Canopy’s Package Manager (you can download Canopy here).
Mayavi 4.5.0 is an important release which adds the following features:
- Jupyter notebook support: Adds basic support for displaying Mayavi images or interactive X3D scenes
- Support for recording movies and animating time series
- Support for the new matplotlib color schemes
- Improvements on the experimental Python 3 support from the previous release
- Compatibility with VTK-5.x, VTK-6.x, and 7.x. For more details on the full set of changes see here.
Let’s take a look at some of these new features in more detail:
Jupyter Notebook Support
This feature is still basic and experimental, but it is convenient. The feature allows one to embed either a static PNG image of the scene or a richer X3D scene into a Jupyter notebook. To use this feature, one should first initialize the notebook with the following:
from mayavi import mlab
mlab.init_notebook()
Subsequently, one may simply do:
s = mlab.test_plot3d()
s
This will embed a 3-D visualization producing something like this:

Embedded 3-D visualization in a Jupyter notebook using Mayavi
When the init_notebook method is called it configures the Mayavi objects so they can be rendered on the Jupyter notebook. By default the init_notebook function selects the X3D backend. This will require a network connection and also reasonable off-screen support. This currently will not work on a remote Linux/OS X server unless VTK has been built with off-screen support via OSMesa as discussed here.
For more documentation on the Jupyter support see here.
Animating Time Series
This feature makes it very easy to animate a time series. Let us say one has a set of files that constitute a time series (files of the form some_name[0-9]*.ext). If one were to load any file that is part of this time series like so:
from mayavi import mlab
src = mlab.pipeline.open('data_01.vti')
Animating these is now very easy if one simply does the following:
src.play = True
This can also be done on the UI. There is also a convenient option to synchronize multiple time series files using the “sync timestep” option on the UI or from Python. The screenshot below highlights the new features in action on the UI:
New time series animation feature in the Python Mayavi 3D visualization library.
Recording Movies
One can also create a movie (really a stack of images) while playing a time series or running any animation. On the UI, one can select a Mayavi scene and navigate to the movie tab and select the “record” checkbox. Any animations will then record screenshots of the scene. For example:
from mayavi import mlab
f = mlab.figure()
f.scene.movie_maker.record = True
mlab.test_contour3d_anim()
This will create a set of images, one for each step of the animation. A gif animation of these is shown below:
More than 50 pull requests were merged since the last release. We are thankful to Prabhu Ramachandran, Ioannis Tziakos, Kit Choi, Stefano Borini, Gregory R. Lee, Patrick Snape, Ryan Pepper, SiggyF, and daytonb for their contributions towards this release.
Additional Resources on Mayavi:
- Mayavi documentation / user guide
- Mayavi example gallery
- SciPy lecture notes, Advanced 3-D Plotting with Mayavi, by Gaël Varoquaux
- Using Mayavi with SciPy: a Tutorial , by Gaël Varoquaux
Related Content
Prospecting for Data on the Web
Introduction At Enthought we teach a lot of scientists and engineers about using Python and the ecosystem of scientific Python packages for processing, analyzing, and…
Configuring a Neural Network Output Layer
Introduction If you have used TensorFlow before, you know how easy it is to create a simple neural network model using the Keras API. Just…
No Zero Padding with strftime()
One of the best features of Python is that it is platform independent. You can write code on Linux, Windows, and MacOS and it works…
Sorting Out .sort() and sorted()
Sorting Out .sort() and sorted() Sometimes sorting a Python list can make it mysteriously disappear. This happens even to experienced Python programmers who use .sort()…
A Beginner’s Guide to Deep Learning
Deep learning. By this point, we’ve all heard of it. It’s the magic silver bullet that can fix any complex problem. It’s the special ingredient…
Giving Visibility to Renewable Energy
The ultimate project goal of EnergizAIR Infrastructure was to raise individual awareness of the contribution of renewable energy sources, and ultimately change behaviors. Now ten…
Introducing Enthought Edge: Unlocking the Value of R&D Data
While the value of R&D data is clear, finding a way to sort through it can be daunting given the special handling required to extract…
Machine Learning in Materials Science
The process of materials discovery is complex and iterative, requiring a level of expertise to be done effectively. Materials workflows that require human judgement present…
AI Needs the ‘Applied Sciences’ Treatment
As industries rapidly advance in AI/machine learning, a key to unlocking the power of these approaches for companies is an enabling environment. Domain experts need…
Join Our Mailing List!
Sign up below to receive email updates including the latest news, insights, and case studies from our team.