3D visualization of scientific data in Python

Related tags

Science mayavi
Overview

Mayavi: 3D visualization of scientific data in Python

Mayavi docs: http://docs.enthought.com/mayavi/mayavi/ TVTK docs: http://docs.enthought.com/mayavi/tvtk

Package on PyPI Build status Appveyor build status Code coverage status BSD 3 Clause

Vision

Mayavi seeks to provide easy and interactive visualization of 3D data. It does this by the following:

  • an (optional) rich user interface with dialogs to interact with all data and objects in the visualization.
  • a simple and clean scripting interface in Python, including one-liners, a-la mlab, or object-oriented programming interface.
  • harnesses the power of the VTK toolkit without forcing you to learn it.

Additionally Mayavi strives to be a reusable tool that can be embedded in your applications in different ways or combined with the envisage application-building framework to assemble domain-specific tools.

Mayavi is part of the Enthought Tool Suite (ETS).

Features

Mayavi is a general purpose, cross-platform tool for 2-D and 3-D scientific data visualization. Its features include:

  • Visualization of scalar, vector and tensor data in 2 and 3 dimensions
  • Easy scriptability using Python
  • Easy extendability via custom sources, modules, and data filters
  • Reading several file formats: VTK (legacy and XML), PLOT3D, etc.
  • Saving of visualizations
  • Saving rendered visualization in a variety of image formats
  • Convenient functionality for rapid scientific plotting via mlab (see mlab documentation)
  • See the Mayavi Users Guide for more information.

Unlike its predecessor MayaVi1, Mayavi has been designed with scriptability and extensibility in mind from the ground up. While the mayavi2 application is usable by itself, it may be used as an Envisage plugin which allows it to be embedded in user applications natively. Alternatively, it may be used as a visualization engine for any application.

Quick start

If you are new to Mayavi it is a good idea to read the online user manual which should introduce you to how to install and use it.

If you have installed Mayavi as described in the next section, you should be able to launch the mayavi2 application and also run any of the examples in the examples directory.

Installation

By itself Mayavi is not a difficult package to install but its dependencies are unfortunately rather heavy. However, many of these dependencies are now available as wheels on PyPI. The two critical dependencies are,

  1. VTK
  2. A GUI toolkit, either PyQt4, PySide, PySide2, PyQt5 or wxPython.

The latest VTK wheels are available on all the major platforms (Windows, MacOS, and Linux), but only for 64 bit machines. Python 3.x is fully supported on all these operating systems and Python 2.7.x on MacOS and Linux. If you are out of luck, and your platform is not supported then you will need to install VTK yourself using your particular distribution as discussed in the General Build and Installation instructions

On Python 3.x you will need to install PyQt5 and wheels are available for this. On 2.7.x you have more options, and can use PySide, PyQt4, and wxPython. These can be installed from pip or from your package manager.

Currently, Mayavi itself should work with the new wxPython 4.x. However, traitsui, pyface, and other ETS packages do not yet support it so the UI will not work correctly. Older versions should work. PyQt/PySide/PySide2 should work largely out of the box.

Latest stable release

As of the latest release, i.e. 4.6.0 and above, if you are using Python 3.x and are on a 64 bit machine, installation via pip is the easiest and is as follows:

$ pip install mayavi

$ pip install PyQt5

Thats it!

If you are unable to do this, read the documentation above and find a way to install VTK and a suitable UI toolkit and then repeat the above.

If you are interested in the jupyter notebook support as well, do the following (after ensuring that you have jupyter installed of course):

$ jupyter nbextension install --py mayavi --user
$ jupyter nbextension enable --py mayavi --user

You will also need to have ipywidgets and ipyevents installed. These can be installed via pip or your favorite package manager.

Bleeding edge

If you want to install the latest version of Mayavi from github, you can simply do the following:

$ git clone https://github.com/enthought/mayavi.git
$ cd mayavi
$ pip install -r requirements.txt
$ pip install PyQt5  # replace this with any supported toolkit
$ python setup.py install  # or develop

Add the jupyter nbextensions using the instructions in the section above and you should be good to go.

Documentation

More documentation is available in the online user manual or in docs directory of the sources. This includes a man page for the mayavi2 application, a users guide in HTML and PDF format and documentation for mlab.

More documentation in the form of workshop/tutorial material is available here:

Tutorial Videos

Here are some tutorial videos that you can watch to learn Mayavi:

Examples

Examples are all in the examples directory of the source or the git clone. The docs and examples do not ship with the binary eggs. The examples directory also contains some sample data.

Test suite

The basic test suites for tvtk and mayavi can be run using nose:

nosetests -v tvtk/tests
nosetests -v mayavi

The integration tests:

cd integrationtests/mayavi
python run.py

Bug tracker, mailing list etc.

The bug tracker is available in github Please provide info and details on platform, python, vtk and gui backends and their versions. If possible, a small example replicating the the problem.

If you have questions you could ask on the Mayavi-users mailing list. This is used by some folks and is not too active. Another mailing list that may be of use is the ETS Users mailing list. This is a more general list where a lot of folks experienced with the Enthought Tool Suite are available.

Authors and Contributors

  • Core contributors:

    Prabhu Ramachandran: primary author.

  • Previous contributors:

    Gaël Varoquaux: mlab, icons, many general improvements and maintenance.

    Deepak Surti: Upgrade to VTK 5.10.1, VTK 6.x with new pipeline.

  • Support and code contributions from Enthought Inc.

  • Patches from many people (see the release notes), including K K Rai and R A Ambareesha for tensor support, parametric source and image data.

    Many thanks to all those who have submitted bug reports and suggestions for further enhancements.

Comments
  • Python 3 support

    Python 3 support

    Any plan to support Python 3 for mayavi ?

    Python going to release Python 3.4 soon. I think Python 3 is now very mature and main third party library (numpy, scipy, pandas, matplotlib, etc) support it now.

    I am also slowly moving all my project to Python 3. It's pretty simple task with 2to3 app for "small" project. You can sometime get some conflict with old std libs or issues with unicode/string stream but nothing bad...

    I guess it will be a bit more complicated to move mayavi and others related projects but it shouldn't be something too hard to do in a mid term time.

    I don't want to talk for others but I think many people are waiting mayavi to move their projects to Python 3.

    "Don't wait until Python 4 is released please..."

    :-)

    Cheers

    opened by hadim 72
  • Upgrading to new pipeline

    Upgrading to new pipeline

    Step 1: Changing the pipeline topology. [IN PROGRESS]

    Step 2: Changing the pipeline metadata

    Step 3: Update only the algorithms, and not a combination of data objects/algorithms.

    Step 4: (VTK 6 only): Subclass only from vtkAlgorithm and use the RequestXXXX api

    opened by dmsurti 70
  • 3D Visualizer / TVTK Window (Not Responding) on Windows 7 64-Bit

    3D Visualizer / TVTK Window (Not Responding) on Windows 7 64-Bit

    I am working to install Mayavi2 on my Windows 7 (64 Bit), but am not able to fully interact with the visualizer or TVTK window. They freeze immediately upon first opening. I have tried to install Mayavi2 using both the Enthought (64 Bit & 32 Bit) and Python(x,y) distributions with full system cleans before the installation to ensure that all Python materials are removed. Each installation allows me to interact with Python with no noticeable trouble and I am able to "import mayavi" to my shell. The problem comes when calling a mayavi function (e.g., mlab.plot3d) or simply running the Mayavi2 GUI. Immediately the window freezes and shows a (Not Responding) message. I have tried to install the package on another Windows 7 (64 Bit) machine with no problem. Thanks for the help. I am very interested to see if there is a machine-specific solution to my problem or what I might try to get around this window crash.

    opened by brymz 29
  • Stuck at `Building wheel for mayavi (setup.py)`

    Stuck at `Building wheel for mayavi (setup.py)`

    Here is my installation environment: Ubuntu 20.04 LTS on a ThinkPad P15 laptop image And when I do pip install mayavi, I get stuck during the Building wheel process: image

    Python version is 3.8.10.

    opened by woochangchung 24
  • Test suite hangs on macOS

    Test suite hangs on macOS

    I'm unable to run the test suite (under nose) on macOS, with the latest master of Mayavi in a venv: the test suite hangs with no output.

    Steps to reproduce: here are the commands I'm issuing, in a zsh shell on macOS 10.15.7 (Intel MacBook Pro). Here python3.9 is Python 3.9.7, installed via MacPorts.

    python3.9 -m venv --clear ~/.venvs/mayavi
    source ~/.venvs/mayavi/bin/activate
    python -m pip install -e .
    python -m pip install nose
    python -m nose.core -v mayavi
    

    Note: the python -m pip install -e . instruction also hangs intermittently (perhaps 1 run out of every 3), but succeeds often enough to allow me to get to the next step.

    When the installation succeeds, the test run using nose hangs with no output other than a RuntimeWarning about nose.core being found in sys.modules prior to execution of nose.core. The hang can't be interrupted with a Ctrl-C, and top shows no CPU usage or memory growth in the associated process - IOW the hang resembles a deadlock of some kind. The Python process shows 7 OS-level threads; I'm not sure what's causing the extra threads in something that I'd expect to be single-threaded.

    There's at least one obvious problem with my setup, which is that I know that the test suite expects some other packages to be present, and will fail without them. However, this still shouldn't be responsible for hanging the test run - we should have a better failure mode here.

    I consider this sort of issue to be high priority to diagnose and fix: it makes development work much harder than it needs to be.

    bug 
    opened by mdickinson 23
  • text3d and fullscreen

    text3d and fullscreen

    On my system mayavi 4.4.0 (and the previous version) will make the text3d disappear when the window is made fullscreen.

    Procedure:

    from mayavi import mlab
    mlab.points3d(0, 0, 0, opacity=0.5)
    mlab.text3d(0, 0, 0, 'A')
    mlab.show()
    

    After these commands a sphere and an A is displayed. Pressing the fullscreen button makes the text3d disappear from the scene. The Text3D object is still visible in the 'Mayavi pipline' window.

    needs investigation bug 
    opened by fnielsen 22
  • Does Mayavi support PyQt5?

    Does Mayavi support PyQt5?

    Hi all!

    I want to embed a mayavi surface plot into a PyQt5 widget, like I did with matplotlib plots. Alas, I didn't find any working examples of such an embedding.

    Is PyQt5 supported now?

    opened by Felix-neko 20
  • Python3 support

    Python3 support

    The aim of this PR is to solicit feedback and merge this early for those who want to cut themselves on the bleeding edge.

    This adds experimental Python3 support for Mayavi. To use it one requires a recent version of apptools and envisage (by recent I mean that these PRs should be merged https://github.com/enthought/apptools/pull/54 and https://github.com/enthought/envisage/pull/61 ).

    It requires the master branch of pyface.

    It will require the latest version of VTK from their git repository (https://gitlab.kitware.com/vtk/vtk) and a fresh build of VTK configured for Python3. I have not bothered with travis CI support at this point due to the complexity of doing that. These changes pass all current 2.7.x tests on travis so should be safe to merge.

    Status and known issues

    • The changes are compatible with Python 2.x and 3.x. I have tested on 2.7.x and 3.4.x.
    • All the tvtk tests pass.
    • There are a couple of random failures in the mayavi tests. These may be version specific issues but need more investigation.
    • The integration tests mostly run fine but blocks on exit (with PyQt) so if you run one of them you need to kill it to run the next. This can be investigated later.
    • mlab works quite well.
    • The mayavi2 application itself has a few issues that seem pyface related and will be investigated later, notably the persistence of the workbench perspectives are not pickled/unpickled properly..
    opened by prabhuramachandran 20
  • Fix

    Fix "_p_void" values in TVTK with VTK 6.x

    I have tested this with VTK 6.2 and 6.3 on Ubuntu 12, and VTK 6.3 on OSX 10.11

    Things seem to work but since this is a fundamental change, I would prefer sitting on it for a bit longer. Review and comments are very much appreciated.

    Most of these changes are tested by the existing TVTK test for initialising all classes, but I think I could also add more tests to make it more robust.

    To compare the bahaviour, try the following with the master branch and with this one:

    from tvtk.api import tvtk
    obj = tvtk.ViewTheme()
    obj.configure_traits()
    
    opened by kitchoi 19
  • MAINT: Update for latest VTK

    MAINT: Update for latest VTK

    Closes #1049

    @opoplawski can you see if this fixes your build hang on Fedora 34? It at least "fixes" the hang for me on Windows. Plotting still doesn't work there (mlab.test_plot3d()) despite pyvistaqt.BackgroundPlotter working okay, so there is more to fix. But this might already be good enough progress in that it will prevent total pip install hangs for people using the VTK pre wheels. (They'll have a problem later when they try to actually plot, but that's at least easier to diagnose than an empty build log that took an hour of CI time).

    opened by larsoner 18
  • ENH: VTK 9 compat

    ENH: VTK 9 compat

    This is a bit nightmarish to figure out, but I'm about halfway through adding exceptions for the objects. There is probably an automated way to do it, might be worth figuring that out...

    Closes #908.

    opened by larsoner 18
  • Recurrence of #281 (keeping a key pressed )

    Recurrence of #281 (keeping a key pressed )

    I already posted a comment in the issue #281 thread, but since it is closed, I am opening a new issue.

    As originally described, and as now occurs again:

    'On a slower system, like a Linux Virtual Machine, I observed an occasional traceback when pressing a key (say, z) and rotating the scene with the mouse: [...] TypeError: SetEventInformationFlipY argument 5: a string of length 1 is required'

    I found that the original fix for #281 needs to be modified slightly in the source code for QVTKRenderWindowInteractor.py:

    if ev.isAutoRepeat():
    # key = key[0]
    key = bytes(key[0])

    (apologies I am not a formatting wiz here)

    opened by cvsindelar 0
  • Opacity not working on volume_slice and image plane widget

    Opacity not working on volume_slice and image plane widget

    Hi, I have a scalar 3D cube where I want to add opacity to some slices but it is not possible with volume_slice and image plane widget. The only current solution was to use scalar cut plane (where opacity works). Is it possible for me to add opacity via pipeline to image plane widget? Thanks in advance!

    opened by ammir1 0
  • Hello! When I use mayavi to visualize the point cloud, the following error appears: ImportError: Could not import backend for trainsui Make sure you  have a suitable UI toolkit like PyQt/PySide or wxPython  installed.

    Hello! When I use mayavi to visualize the point cloud, the following error appears: ImportError: Could not import backend for trainsui Make sure you have a suitable UI toolkit like PyQt/PySide or wxPython installed.

    Hello! My environment is ubuntu18.04, python 3.7.When I use mayavi to visualize the point cloud, the following error appears: ImportError: Could not import backend for trainsui Make sure you have a suitable UI toolkit like PyQt/PySide or wxPython installed. screenshot_69

    But I have installed the required dependencies.

    scre
screenshot_65
enshot_68 screenshot_67

    I also defined the path of environment variables according to your suggestions to others:

    screenshot_70

    But this problem still exists. It's been bothering me for a long time. It's crazy. Could you help me?Thank you very much,sorry for your inconvenience.

    opened by Yuepengxin 8
  • how to install mayavi with ptyhon 3.9 on ubuntu 22.04 by conda?

    how to install mayavi with ptyhon 3.9 on ubuntu 22.04 by conda?

    Environment:

    os:Ubuntu 22.04
    conda: 22.9.0
    python: 3.9.13
    

    when I planned to install mayavi by conda, it was sticked there: image

    What's the problem, and how to resolve it?

    opened by heavenkiller2018 1
  • Error with configobj while installing

    Error with configobj while installing

    Collecting configobj Using cached configobj-5.0.6.tar.gz (33 kB) Preparing metadata (setup.py) ... error error: subprocess-exited-with-error

    × python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [6 lines of output] Traceback (most recent call last): File "", line 36, in File "", line 34, in File "C:\temp\pip-install-29s4msxx\configobj_9b92c695733840439ec2e6a1e365cf8d\setup.py", line 17, in from _version import version ModuleNotFoundError: No module named '_version' [end of output]

    opened by yeney 0
Releases(4.7.3)
  • 4.7.3(May 11, 2021)

  • 4.5.0(Aug 3, 2016)

    Enhancements

    • Jupyter notebook support
    • Adds support for recording movies and animating timesteps.
    • Updated LUTs to include new matplotlib colorschemes

    Fixes

    • Fix several bugs where PDF files were not saved properly.
    • Fix issues with tvtk.visual and add many tests for it
    • Refactor the save screenshot dialog popups.
    • Fix problem with the picker point not showing when "p" is pressed on the scene.
    • Python 3 fixes for the jupyter notebook support.
    • Fixes tubes not showing on protein demo.
    • Add additional save options.
    • Fixes the image plane widget and volume modules
    • Debug info on code gen for wrapper generation
    • BUG: Fix slice unstructured grid module.
    • Fix typo in readme.
    • update codecov configuration
    • Documentation for QString API failure.
    • Fixes incorrect signature of EnvisageEngine.new_scene.
    • Fix for unexpected test code.
    • Fix "_p_void" values in TVTK with VTK 6.x
    • Fix failing test for custom import in some circumstances
    • Removes array_ext.so/pyd on clean
    • Check if test successful with the appropriate filename.
    • Unicode trait handling for those vtk methods returning unicode data
    • Nicely load pylab_luts.pkl
    • Document object identity behavior matching VTK
    • Revert "Fix savefig size and black image"
    • Added setup.py documentation for Qt requirements
    • Add VTK 6.3 and VTK 7 to travis ci
    • Fix traitsdoc setup and compliance with py3
    • Import and integer division in python3
    • Fix texture on mlab.surf
    • Fixes Quiver3d Failure with different argument types
    • Fix Text3D in VTK 6.0+
    • Fix savefig size and black image
    • Fix for exception when modifying extents
    • Suppresses test for VTK 6.2 (solves appVeyor random failure)
    • Forces pipeline update when LUT changes
    • Fix for test failure on mayavi -t
    • Enforce ordering of attribute labels in VTKDataSource.
    • Apply has_attribute to the output in VTKFileReader
    • Replacing links to code. and svn.enthought.com
    • Fix Camera off-centered when loading saved visualization
    • Update to use new VTK pipeline where possible. This fixes a number of issues with the pipeline was not updating properly.
    • Fix issue with mlab.move
    • Fix issue with segfault when savefig is called multiple times.
    • Fix get_engine behavior when backend is changed again.

    Contributions from itziakos, stefanoborini and kitchoi are funded and supported by the SimPhoNy project, an EU-project funded by the 7th Framework Programme (Project number 604005) under the call NMP.2013.1.4-1.

    Source code(tar.gz)
    Source code(zip)
  • 4.4.4(Jun 28, 2016)

    Enhancements

    • Add experimental Python3 support

    Fixes

    • Ensure the cut plane is updated when the plane is changed in the GUI
    • Use off screen engine when mlab's offscreen option is enabled
    • Cast the window id to an int in the render window interactor
    • Update installation guide
    • Update docs to use Qt instead of wx
    • Update documentation setup
    • Allow TVTK to be used without UI/X server
    • Update documentation links
    • Make sure the array shape and size match
    • Ensure file attribute points to the correct path when running a script from Mayavi2
    • Avoid multiple identical keys in keyPressEvent. This is observed on slow machines
    • Do not use get-pip or wheel to upgrade pip on appveyor
    • Fix broken link in docs left hand side menu bar
    Source code(tar.gz)
    Source code(zip)
  • 4.4.3(Aug 19, 2015)

    Enhancements

    • Update the readme fixing dead links
    • Use new Travis CI containers for faster builds
    • Add CI tests on Windows using Appveyor

    Fixes

    • Remove reference cycles from various objects to fix memory leaks.
    • Add unittest that provides an API to test garbage collection.
    • Fix the LUT manager to select the correct lut mode for QT backend
    • Use the python-wxtool package to speed up Travis CI build
    • Fix TVTK wrapper to allow look up with long keys for Points
    • Fix glyph to handle the masking of input points
    • Update the docs with known bugs, issues list and describe the PR workflow on github for development and documentation.
    • Fix TVTK wrapper to update number of cells when a cell is inserted in a VTK cell array
    • Fix VKTFileReader to update output when using standalone
    • Fix the sdist command
    Source code(tar.gz)
    Source code(zip)
  • 4.4.2(Jun 18, 2015)

SCICO is a Python package for solving the inverse problems that arise in scientific imaging applications.

Scientific Computational Imaging COde (SCICO) SCICO is a Python package for solving the inverse problems that arise in scientific imaging applications

Los Alamos National Laboratory 37 Dec 21, 2022
Veusz scientific plotting application

Veusz 3.3.1 Veusz is a scientific plotting package. It is designed to produce publication-ready PDF or SVG output. Graphs are built-up by combining pl

Veusz 613 Dec 16, 2022
Kedro is an open-source Python framework for creating reproducible, maintainable and modular data science code

A Python framework for creating reproducible, maintainable and modular data science code.

QuantumBlack Labs 7.9k Jan 1, 2023
Efficient Python Tricks and Tools for Data Scientists

Why efficient Python? Because using Python more efficiently will make your code more readable and run more efficiently.

Khuyen Tran 944 Dec 28, 2022
An interactive explorer for single-cell transcriptomics data

an interactive explorer for single-cell transcriptomics data cellxgene (pronounced "cell-by-gene") is an interactive data explorer for single-cell tra

Chan Zuckerberg Initiative 424 Dec 15, 2022
Data intensive science for everyone.

The latest information about Galaxy can be found on the Galaxy Community Hub. Community support is available at Galaxy Help. Galaxy Quickstart Galaxy

Galaxy Project 1k Jan 8, 2023
🍊 :bar_chart: :bulb: Orange: Interactive data analysis

Orange Data Mining Orange is a data mining and visualization toolbox for novice and expert alike. To explore data with Orange, one requires no program

Bioinformatics Laboratory 3.9k Jan 5, 2023
CS 506 - Computational Tools for Data Science

CS 506 - Computational Tools for Data Science Code, slides, and notes for Boston University CS506 Fall 2021 The Final Project Repository can be found

Lance Galletti 14 Mar 23, 2022
A logical, reasonably standardized, but flexible project structure for doing and sharing data science work.

Cookiecutter Data Science A logical, reasonably standardized, but flexible project structure for doing and sharing data science work. Project homepage

Jon C Cline 0 Sep 5, 2021
A framework for feature exploration in Data Science

Beehive A framework for feature exploration in Data Science Background What do we do when we finish one episode of feature exploration in a jupyter no

Steven IJ 1 Jan 3, 2022
Datamol is a python library to work with molecules

Datamol is a python library to work with molecules. It's a layer built on top of RDKit and aims to be as light as possible.

datamol 276 Dec 19, 2022
Incubator for useful bioinformatics code, primarily in Python and R

Collection of useful code related to biological analysis. Much of this is discussed with examples at Blue collar bioinformatics. All code, images and

Brad Chapman 560 Dec 24, 2022
Karate Club: An API Oriented Open-source Python Framework for Unsupervised Learning on Graphs (CIKM 2020)

Karate Club is an unsupervised machine learning extension library for NetworkX. Please look at the Documentation, relevant Paper, Promo Video, and Ext

Benedek Rozemberczki 1.8k Dec 31, 2022
Probabilistic Programming in Python: Bayesian Modeling and Probabilistic Machine Learning with Aesara

PyMC3 is a Python package for Bayesian statistical modeling and Probabilistic Machine Learning focusing on advanced Markov chain Monte Carlo (MCMC) an

PyMC 7.2k Dec 30, 2022
Statsmodels: statistical modeling and econometrics in Python

About statsmodels statsmodels is a Python package that provides a complement to scipy for statistical computations including descriptive statistics an

statsmodels 8.1k Dec 30, 2022
A computer algebra system written in pure Python

SymPy See the AUTHORS file for the list of authors. And many more people helped on the SymPy mailing list, reported bugs, helped organize SymPy's part

SymPy 9.9k Jan 8, 2023
PennyLane is a cross-platform Python library for differentiable programming of quantum computers.

PennyLane is a cross-platform Python library for differentiable programming of quantum computers. Train a quantum computer the same way as a neural network.

PennyLaneAI 1.6k Jan 4, 2023
Float2Binary - A simple python class which finds the binary representation of a floating-point number.

Float2Binary A simple python class which finds the binary representation of a floating-point number. You can find a class in IEEE754.py file with the

Bora Canbula 3 Dec 14, 2021
A simple computer program made with Python on the brachistochrone curve.

Brachistochrone-curve This is a simple computer program made with Python on the brachistochrone curve. I decided to write it after a physics lesson on

Diego Romeo 1 Dec 16, 2021