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
Jupyter AI Magics Are Not ✨Magic✨
It doesn’t take ✨magic✨ to integrate ChatGPT into your Jupyter workflow. Integrating ChatGPT into your Jupyter workflow doesn’t have to be magic. New tools are…
Top 5 Takeaways from the American Chemical Society (ACS) 2023 Fall Meeting: R&D Data, Generative AI and More
By Mike Heiber, Ph.D., Materials Informatics Manager Enthought, Materials Science Solutions The American Chemical Society (ACS) is a premier scientific organization with members all over…
Real Scientists Make Their Own Tools
There’s a long history of scientists who built new tools to enable their discoveries. Tycho Brahe built a quadrant that allowed him to observe the…
How IT Contributes to Successful Science
With the increasing importance of AI and machine learning in science and engineering, it is critical that the leadership of R&D and IT groups at...
From Data to Discovery: Exploring the Potential of Generative Models in Materials Informatics Solutions
Generative models can be used in many more areas than just language generation, with one particularly promising area: molecule generation for chemical product development.
7 Pro-Tips for Scientists: Using LLMs to Write Code
Scientists gain superpowers when they learn to program. Programming makes answering whole classes of questions easy and new classes of questions become possible to answer….
The Importance of Large Language Models in Science Even If You Don’t Work With Language
OpenAI's ChatGPT, Google's Bard, and other similar Large Language Models (LLMs) have made dramatic strides in their ability to interact with people using natural language....
4 Reasons to Learn Xarray and Awkward Array—for NumPy and Pandas Users
You know it. We know it. NumPy is cool. Pandas is cool. We can bend them to our will, but sometimes they’re not the right tools…
Leveraging AI in Cell Culture Analysis
Mammalian cell culture is a fundamental tool for many discoveries, innovations, and products in the life sciences.
7 Lesser-Known Command Line Tools That Ship with Python
Like most people, I mostly interact with Python using the default REPL or with IPython. Yet, I often reach for one of the Python tools…