### Install Mayavi from source Source: https://docs.enthought.com/mayavi/mayavi/_sources/installation.rst.txt Steps to clone the repository and install the development version of Mayavi. ```bash $ 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 ``` -------------------------------- ### Run Mayavi Script from Examples Directory Source: https://docs.enthought.com/mayavi/mayavi/_sources/example_fire.rst.txt Navigate to the examples directory and execute a Mayavi Python script using the 'python' command. ```bash cd examples python streamline.py ``` -------------------------------- ### Start IPython with Pylab support Source: https://docs.enthought.com/mayavi/mayavi/_sources/mlab_running_scripts.rst.txt Use the --pylab=qt option when starting IPython to enable Pylab mode with Qt support. ```bash $ ipython --pylab=qt ``` -------------------------------- ### Run streamline.py example with Python Source: https://docs.enthought.com/mayavi/mayavi/example_fire.html Execute the streamline.py script using the Python interpreter. Ensure you are in the 'examples' directory. ```bash $ cd examples $ python streamline.py ``` -------------------------------- ### Start IPython with Pylab Qt Source: https://docs.enthought.com/mayavi/mayavi/mlab.html Launch IPython with the pylab interface and Qt backend enabled. ```bash ipython --pylab=qt ``` -------------------------------- ### Build Mayavi Documentation Source: https://docs.enthought.com/mayavi/mayavi/misc.html Run this command in the base directory of your checkout to build the HTML documentation. Sphinx must be installed. ```bash python setup.py build_docs ``` -------------------------------- ### Set camera view parameters Source: https://docs.enthought.com/mayavi/mayavi/auto/mlab_camera.html Examples of setting various camera view properties. ```python >>> view(45, 45) >>> view(240, 120) >>> view(distance=20) >>> view(focalpoint=(0,0,9)) ``` -------------------------------- ### Install Mayavi via pip Source: https://docs.enthought.com/mayavi/mayavi/_sources/installation.rst.txt Standard installation command for the latest stable release of Mayavi and a required GUI toolkit. ```bash $ pip install mayavi $ pip install PyQt5 ``` -------------------------------- ### Run streamline.py example with mayavi2 Source: https://docs.enthought.com/mayavi/mayavi/example_fire.html Launch the streamline.py script using the mayavi2 command-line interface. This is an alternative way to run the example. ```bash $ mayavi2 -x streamline.py ``` -------------------------------- ### Mayavi Datasets Example Source: https://docs.enthought.com/mayavi/mayavi/auto/example_datasets.html This Python script demonstrates how to create and visualize different types of data sets in Mayavi. It serves as a practical example for understanding Mayavi's data representation capabilities. ```python # Author: Gael Varoquaux # Copyright (c) 2008, Enthought, Inc. ``` -------------------------------- ### Start IPython with Matplotlib support Source: https://docs.enthought.com/mayavi/mayavi/_sources/mlab_running_scripts.rst.txt Start IPython with the --matplotlib=qt option to enable Matplotlib's interactive plotting alongside Mayavi's mlab. ```bash $ ipython --matplotlib=qt ``` -------------------------------- ### Run Mayavi Application Source: https://docs.enthought.com/mayavi/mayavi/_sources/installation.rst.txt Execute the Mayavi application from the command line to test the installation. Use the -h flag for help. ```bash mayavi2 ``` ```bash mayavi2 -h ``` -------------------------------- ### start_recording Source: https://docs.enthought.com/mayavi/mayavi/_sources/auto/mlab_other_functions.rst.txt Start automatic script recording. ```APIDOC ## start_recording(ui=True) ### Description Start automatic script recording. If the ui parameter is True, it creates a recorder with a user interface. ### Response - **Recorder** (instance) - The Recorder instance created. ``` -------------------------------- ### Run Mayavi Standalone Source: https://docs.enthought.com/mayavi/mayavi/_sources/auto/example_standalone.rst.txt Demonstrates the basic setup for using Mayavi independently of the Envisage application framework. ```python from mayavi import mlab # Create a simple plot mlab.test_plot3d() # Show the visualization mlab.show() ``` -------------------------------- ### Manage virtual display in Python Source: https://docs.enthought.com/mayavi/mayavi/_sources/tips.rst.txt Use the pyvirtualdisplay library to programmatically start a virtual display. ```python from pyvirtualdisplay import Display import os display = Display(visible=0, size=(1280, 1024)) display.start() ``` -------------------------------- ### Start IPython with Qt GUI Source: https://docs.enthought.com/mayavi/mayavi/mlab.html Launch IPython with the Qt GUI enabled for interactive plotting. This is an alternative to --matplotlib=qt. ```bash ipython --gui=qt ``` -------------------------------- ### Install Mayavi with EDM (Python 2.7) Source: https://docs.enthought.com/mayavi/mayavi/_sources/installation.rst.txt Use this command to install Mayavi and PyQt for the default Python 2.7 environment managed by EDM. ```bash edm install mayavi pyqt ``` -------------------------------- ### Start New Module Manager Source: https://docs.enthought.com/mayavi/mayavi/_sources/application.rst.txt Starts a new module manager for the Mayavi pipeline. Useful for managing multiple visualization pipelines. ```bash mayavi2 -M ``` ```bash mayavi2 --module-mgr ``` -------------------------------- ### show Source: https://docs.enthought.com/mayavi/mayavi/_sources/auto/mlab_other_functions.rst.txt Start interacting with the figure or decorate a function requiring a UI. ```APIDOC ## show(func=None, stop=False) ### Description Start interacting with the figure. By default, this function creates a GUI and starts its event loop if needed. It can also be used as a decorator. ### Parameters - **func** (callable) - Optional - Function to decorate. - **stop** (boolean) - Optional - If True, pops up a UI where the user can stop the event loop. ``` -------------------------------- ### Setup grid and coil configuration Source: https://docs.enthought.com/mayavi/mayavi/auto/example_magnetic_field.html Initializes the evaluation grid and defines the coil parameters for field calculation. ```python ############################################################################## # The grid of points on which we want to evaluate the field X, Y, Z = np.mgrid[-0.15:0.15:31j, -0.15:0.15:31j, -0.15:0.15:31j] # Avoid rounding issues : f = 1e4 # this gives the precision we are interested by : X = np.round(X * f) / f Y = np.round(Y * f) / f Z = np.round(Z * f) / f r = np.c_[X.ravel(), Y.ravel(), Z.ravel()] ############################################################################## # The coil positions # The center of the coil r0 = np.r_[0, 0, 0.1] # The normal to the coils n = np.r_[0, 0, 1] # The radius R = 0.1 # Add the mirror image of this coils relatively to the xy plane : r0 = np.vstack((r0, -r0 )) R = np.r_[R, R] n = np.vstack((n, n)) # Helmoltz like configuration ############################################################################## # Calculate field # First initialize a container matrix for the field vector : B = np.empty_like(r) ``` -------------------------------- ### Enable Jupyter Notebook support Source: https://docs.enthought.com/mayavi/mayavi/_sources/installation.rst.txt Commands to install and enable the Mayavi Jupyter notebook extension. ```bash $ jupyter nbextension install --py mayavi --user $ jupyter nbextension enable --py mayavi --user ``` -------------------------------- ### Initialize Mayavi Scripting Source: https://docs.enthought.com/mayavi/mayavi/_sources/advanced_scripting.rst.txt Start the Mayavi application or use mlab to access the engine and scene. ```python from mayavi.plugins.app import main # Note, this does not process any command line arguments. mayavi = main() # 'mayavi' is the mayavi Script instance. ``` ```python from mayavi import mlab f = mlab.figure() # Returns the current scene. engine = mlab.get_engine() # Returns the running mayavi engine. ``` -------------------------------- ### Create a 3D contour plot with mlab Source: https://docs.enthought.com/mayavi/mayavi/_sources/data.rst.txt This example shows how to generate a 3D contour plot from a NumPy array using Mayavi's mlab module. Ensure numpy and mayavi are installed. ```python import numpy as np from mayavi import mlab data = np.random.random((10, 10, 10)) iso = mlab.contour3d(data) ``` -------------------------------- ### Animate Visualization with Dynamic Data Update Source: https://docs.enthought.com/mayavi/mayavi/_sources/tips.rst.txt This example uses the @mlab.animate decorator to continuously update data points in a 3D plot. It requires numpy for array manipulation and mlab.show() to start the event loop. ```python import numpy as np from mayavi import mlab @mlab.animate(delay = 100) def updateAnimation(): t = 0.0 while True: ball.mlab_source.set(x = np.cos(t), y = np.sin(t), z = 0) t += 0.1 yield ball = mlab.points3d(np.array(1.), np.array(0.), np.array(0.)) updateAnimation() mlab.show() ``` -------------------------------- ### Initialize Engine and Add Source Source: https://docs.enthought.com/mayavi/mayavi/_sources/advanced_scripting.rst.txt Demonstrates initializing the Mayavi engine, creating a new scene, adding a parametric surface source, and internally calling its start method. ```python from mayavi.api import Engine e = Engine() e.start() s = e.new_scene() from mayavi.sources.api import ParametricSurface p = ParametricSurface() e.add_source(p) # calls p.start internally. p.remove() # Removes p from the engine. ``` -------------------------------- ### Run Mayavi Standalone Source: https://docs.enthought.com/mayavi/mayavi/auto/example_standalone.html Use this script to run Mayavi in a standalone mode. It requires Mayavi and pyface to be installed. The script sets up an engine, adds data sources and modules, and starts the GUI event loop. ```python # Author: Prabhu Ramachandran # Copyright (c) 2007, Enthought, Inc. # License: BSD Style. from os.path import join, abspath from pyface.api import GUI # The core Engine. from mayavi.core.api import Engine from mayavi.core.ui.engine_view import EngineView # Usual MayaVi imports from mayavi.scripts.util import get_data_dir from mayavi.sources.api import VTKXMLFileReader from mayavi.modules.api import Outline, ScalarCutPlane, Streamline def main(): # Create the MayaVi engine and start it. e = Engine() # Starting the engine registers the engine with the registry and # notifies others that the engine is ready. e.start() # Do this if you need to see the MayaVi tree view UI. ev = EngineView(engine=e) ui = ev.edit_traits() # Create a new scene. scene = e.new_scene() # Now create a new scene just for kicks. scene1 = e.new_scene() # Now setup a normal MayaVi pipeline. src = VTKXMLFileReader() src.initialize(join(get_data_dir(abspath(__file__)), 'fire_ug.vtu')) e.add_source(src) e.add_module(Outline()) e.add_module(ScalarCutPlane()) e.add_module(Streamline()) return e, ui if __name__ == '__main__': # When main returns the ui to go out of scope and be gc'd causing the view # to disappear with qt4. e, ui = main() # Create a GUI instance and start the event loop. We do this here so that # main can be run from IPython -wthread if needed. gui = GUI() gui.start_event_loop() ``` -------------------------------- ### Display Help Information Source: https://docs.enthought.com/mayavi/mayavi/_sources/application.rst.txt Prints all available command-line options and exits. Use this to see all possible arguments. ```bash mayavi2 -h ``` ```bash mayavi2 --help ``` -------------------------------- ### Remote Scripting via Telnet to Mayavi TCP Server Source: https://docs.enthought.com/mayavi/mayavi/_sources/tips.rst.txt After starting the TCP server, you can connect using telnet to execute commands remotely. This example shows how to change camera angles, clear the scene, and load new data. ```bash $ telnet localhost 8007 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. scene.camera.azimuth(45) mlab.clf() mlab.test_contour3d() scene.camera.zoom(1.5) ``` -------------------------------- ### Install Mayavi with Conda-forge Source: https://docs.enthought.com/mayavi/mayavi/installation.html Steps to install Mayavi using the conda-forge channel. This includes cloning or creating an environment, adding the conda-forge channel, activating the environment, installing dependencies, and finally installing Mayavi. ```bash $ conda create --name pyforge --clone root or $ conda create --name pyforge python=2.7 ``` ```bash $ conda config --add channels conda-forge ``` ```bash $ source activate pyforge ``` ```bash $ conda install vtk ``` ```bash $ conda install pyqt=4 ``` ```bash $ conda install mayavi ``` -------------------------------- ### Activate Conda-forge Environment and Install Dependencies Source: https://docs.enthought.com/mayavi/mayavi/_sources/installation.rst.txt Activate the 'pyforge' environment and install necessary dependencies like VTK and PyQt 4 before installing Mayavi. ```bash source activate pyforge ``` ```bash conda install vtk ``` ```bash conda install pyqt=4 ``` -------------------------------- ### Load Data and Apply Modules Source: https://docs.enthought.com/mayavi/mayavi/_sources/application.rst.txt Demonstrates loading a VTK data file and applying several visualization modules like Axes, Outline, and IsoSurface. ```bash mayavi2 -d heart.vtk -m Axes -m Outline -m GridPlane \ -m ContourGridPlane -m IsoSurface ``` -------------------------------- ### Install Mayavi with Conda Source: https://docs.enthought.com/mayavi/mayavi/installation.html Install Mayavi using Conda. This involves creating a new environment, activating it, and then installing Mayavi from the menpo channel. PyQt version can be specified. ```bash $ conda create -n pyconda python=3.5 pyqt=4 ``` ```bash $ source activate pyconda ``` ```bash $ conda install -c menpo mayavi ``` -------------------------------- ### Start Mayavi Application Instance Source: https://docs.enthought.com/mayavi/mayavi/advanced_scripting.html Import and instantiate the Mayavi application using the `main` function from `mayavi.plugins.app`. This instance can then be used for scripting. ```python from mayavi.plugins.app import main # Note, this does not process any command line arguments. mayavi = main() # 'mayavi' is the mayavi Script instance. ``` -------------------------------- ### Install Mayavi using Conda-forge Source: https://docs.enthought.com/mayavi/mayavi/_sources/installation.rst.txt Install Mayavi from the 'conda-forge' channel after setting up the environment and dependencies. ```bash conda install mayavi ``` -------------------------------- ### Print Help Information Source: https://docs.enthought.com/mayavi/mayavi/application.html Prints all available command line options and exits. Also available via `--help`. ```bash mayavi2 -h ``` -------------------------------- ### Install Mayavi using Conda Source: https://docs.enthought.com/mayavi/mayavi/_sources/installation.rst.txt Install Mayavi from the 'menpo' channel within an activated Conda environment. ```bash conda install -c menpo mayavi ``` -------------------------------- ### Manage Mayavi Pipeline Objects Source: https://docs.enthought.com/mayavi/mayavi/advanced_scripting.html Demonstrates initializing the engine, adding a source, and removing it from the pipeline. Requires an IPython environment with Qt support. ```python >>> from mayavi.api import Engine >>> e = Engine() >>> e.start() >>> s = e.new_scene() >>> from mayavi.sources.api import ParametricSurface >>> p = ParametricSurface() >>> e.add_source(p) # calls p.start internally. >>> p.remove() # Removes p from the engine. ``` -------------------------------- ### Screenshot Integration Example Source: https://docs.enthought.com/mayavi/mayavi/auto/mlab_figure.html Example demonstrating how to use mlab.screenshot() to capture a Mayavi plot and display it using Matplotlib. ```python from mayavi import mlab mlab.test_plot3d() arr = mlab.screenshot() import pylab as pl pl.imshow(arr) pl.axis('off') pl.show() ``` -------------------------------- ### Use wx backend with Mayavi Source: https://docs.enthought.com/mayavi/mayavi/_sources/mlab_running_scripts.rst.txt If the Qt backend is not working, set the ETS_TOOLKIT environment variable to wx and start IPython with the --gui=wx option. ```bash $ ETS_TOOLKIT=wx $ ipython --gui=wx ``` -------------------------------- ### EngineView and EngineRichView Initialization Source: https://docs.enthought.com/mayavi/mayavi/_sources/api/core_view_objects.rst.txt Demonstrates how to instantiate and display a view for a Mayavi engine. ```APIDOC ## EngineView and EngineRichView ### Description These classes provide a graphical interface for interacting with a Mayavi engine instance. ### Usage ```python from mayavi.core.ui.api import EngineView view = EngineView(engine=engine) view.edit_traits() ``` ### Parameters - **engine** (MayaviEngine) - Required - The engine instance to be visualized by the view. ``` -------------------------------- ### Create Virtual Framebuffer X Server Source: https://docs.enthought.com/mayavi/mayavi/tips.html Start a virtual framebuffer X server on Linux. This creates a display environment for rendering without a physical display, useful for headless servers or avoiding interference on desktops. ```bash Xvfb :1 -screen 0 1280x1024x24 -auth localhost ``` -------------------------------- ### Start New Module Manager Source: https://docs.enthought.com/mayavi/mayavi/application.html Starts a new module manager in the Mayavi pipeline. Also available via `--module-mgr`. ```bash mayavi2 -M ``` -------------------------------- ### init_notebook Source: https://docs.enthought.com/mayavi/mayavi/_sources/auto/mlab_other_functions.rst.txt Initializes a backend for Jupyter notebooks. ```APIDOC ## init_notebook ### Description Initialize a suitable backend for Jupyter notebooks. ### Parameters - **backend** (str) - Optional - One of ('itk', 'ipy', 'x3d', 'png'). Default: 'ipy'. - **width** (int) - Optional - Suggested default width. - **height** (int) - Optional - Suggested default height. - **local** (bool) - Optional - Use local copy of x3dom.js. Default: True. ``` -------------------------------- ### Install Jupyter Nbextension for Mayavi Source: https://docs.enthought.com/mayavi/mayavi/tips.html Installs Mayavi's Jupyter nbextension for local X3D viewing without a network connection. This command is typically run once. ```bash $ jupyter nbextension install --py mayavi --user ``` -------------------------------- ### Configure visualization via command line Source: https://docs.enthought.com/mayavi/mayavi/_sources/tips.rst.txt Applies object properties and configurations directly from the shell using the -s flag. ```bash $ mayavi2 -d ParametricSurface -m Glyph \ -s"glyph.glyph.scale_factor=0.1" \ -s"glyph.color_mode='no_coloring'" \ -s"actor.property.color = (1,0,0)" ``` ```bash $ mayavi2 -d ParametricSurface -m Glyph\ -s"glyph.glyph.scale_factor=0.1" \ -s"glyph.color_mode='no_coloring'" \ -s"glyph.glyph_source.glyph_source = last_obj.glyph.glyph_source.glyph_list[-1]" ``` -------------------------------- ### Install Mayavi with EDM Source: https://docs.enthought.com/mayavi/mayavi/installation.html Use this command to install Mayavi and pyqt using the EDM package manager. This is applicable for both Python 2.7 and Python 3.6 environments. ```bash $ edm install mayavi pyqt ``` ```bash $ edm shell ``` ```bash $ edm environments create –version 3.6 py3 ``` ```bash $ edm shell -e py3 ``` ```bash $ edm install mayavi pyqt ``` -------------------------------- ### Configure virtual framebuffer X server Source: https://docs.enthought.com/mayavi/mayavi/_sources/tips.rst.txt Commands to initialize an Xvfb server and export the display for headless rendering. ```bash Xvfb :1 -screen 0 1280x1024x24 -auth localhost $ export DISPLAY=:1 ``` -------------------------------- ### Create UI Similar to Mayavi Application Source: https://docs.enthought.com/mayavi/mayavi/_sources/auto/examples.rst.txt An example demonstrating how to construct a user interface that mirrors the complete Mayavi application's structure within a Traits UI view. Useful for creating custom Mayavi-based applications. ```Python from mayavi.core.api import Pipeline from mayavi.core.scene import Scene from traits.api import HasTraits, Instance from traitsui.api import View, Item, Group class MayaviLikeUI(HasTraits): scene = Instance(Scene, (), {'name': 'Scene'}) def _scene_default(self): return Scene(backend='wx') def traits_view(self): return View( Group( Item('scene', style='custom', resizable=True), show_labels=False ), resizable=True, title='Mayavi-like UI' ) if __name__ == '__main__': ui = MayaviLikeUI() ui.configure_traits() ui.scene.edit_traits() ``` -------------------------------- ### Install Mayavi Jupyter Nbextension Source: https://docs.enthought.com/mayavi/mayavi/_sources/tips.rst.txt Install the Mayavi Jupyter nbextension to locally include x3dom Javascript and CSS files for viewing X3D scenes without a network connection. ```bash jupyter nbextension install --py mayavi --user ``` -------------------------------- ### Construct a Mayavi visualization pipeline using the Engine API Source: https://docs.enthought.com/mayavi/mayavi/_sources/advanced_scripting.rst.txt Demonstrates building a visualization pipeline by explicitly instantiating and adding sources, filters, and modules to a Mayavi engine. Requires an active GUI mainloop, such as starting IPython with --gui=qt. ```python import numpy as np a = np.random.random((4, 4)) from mayavi.api import Engine e = Engine() e.start() s = e.new_scene() from mayavi.sources.api import ArraySource src = ArraySource(scalar_data=a) e.add_source(src) from mayavi.filters.api import WarpScalar, PolyDataNormals warp = WarpScalar() e.add_filter(warp, obj=src) normals = PolyDataNormals() e.add_filter(normals, obj=warp) from mayavi.modules.api import Surface surf = Surface() e.add_module(surf, obj=normals) ``` -------------------------------- ### Initialize Mayavi Figure Source: https://docs.enthought.com/mayavi/mayavi/auto/example_flight_graph.html Sets up the Mayavi visualization environment with a specific background and foreground color. Requires 'mayavi.mlab'. ```python ############################################################################### from mayavi import mlab mlab.figure(1, bgcolor=(0.48, 0.48, 0.48), fgcolor=(0, 0, 0), size=(400, 400)) mlab.clf() ``` -------------------------------- ### Start TCP Server for Mayavi Scripting Source: https://docs.enthought.com/mayavi/mayavi/_sources/tips.rst.txt Use this snippet to start a TCP server that listens on port 8007 by default. Any data sent to the server is executed as Python code, with 'engine', 'scene', 'camera', and 'mlab' available for scripting. No need to call mlab.show(). ```python from mayavi import mlab from mayavi.tools import server mlab.test_plot3d() server.serve_tcp() ``` -------------------------------- ### Full Mayavi Scripting Example Source: https://docs.enthought.com/mayavi/mayavi/advanced_scripting.html This script demonstrates creating a new scene, loading data, adding visualization modules (Outline, IsoSurface, Streamline), configuring their properties, saving an image, and creating an animation. ```python # Create a new mayavi scene. mayavi.new_scene() # Get the current active scene. s = mayavi.engine.current_scene # Read a data file. d = mayavi.open('fire_ug.vtu') # Import a few modules. from mayavi.modules.api import Outline, IsoSurface, Streamline # Show an outline. o = Outline() mayavi.add_module(o) o.actor.property.color = 1, 0, 0 # red color. # Make a few contours. iso = IsoSurface() mayavi.add_module(iso) iso.contour.contours = [450, 570] # Make them translucent. iso.actor.property.opacity = 0.4 # Show the scalar bar (legend). iso.module_manager.scalar_lut_manager.show_scalar_bar = True # A streamline. st = Streamline() mayavi.add_module(st) # Position the seed center. st.seed.widget.center = 3.5, 0.625, 1.25 st.streamline_type = 'tube' # Save the resulting image to a PNG file. s.scene.save('test.png') # Make an animation: for i in range(36): # Rotate the camera by 10 degrees. s.scene.camera.azimuth(10) # Resets the camera clipping plane so everything fits and then # renders. s.scene.reset_zoom() # Save the scene. s.scene.save_png('anim%d.png'%i) ``` -------------------------------- ### GET mayavi.tools.pipeline.traverse Source: https://docs.enthought.com/mayavi/mayavi/auto/mlab_pipeline_tools.html Traverses a tree by accessing the nodes' children attribute. ```APIDOC ## GET mayavi.tools.pipeline.traverse ### Description Generator to traverse a tree accessing the nodes' children attribute. ### Parameters #### Query Parameters - **node** (object) - Required - The root node to start traversal. ``` -------------------------------- ### Initialize and Configure Volume Slicer Source: https://docs.enthought.com/mayavi/mayavi/auto/example_volume_slicer_advanced.html Sets up the Mayavi scene, configures interaction styles, and defines initial view parameters for the volume slicer. ```python if axis_name is 'y': position = position[::-1] self.position = position ipw.ipw.add_observer('InteractionEvent', move_view) ipw.ipw.add_observer('StartInteractionEvent', move_view) # Center the image plane widget ipw.ipw.slice_position = 0.5*self.data.shape[ self._axis_names[axis_name]] # 2D interaction: only pan and zoom scene.scene.interactor.interactor_style = \ tvtk.InteractorStyleImage() scene.scene.background = (0, 0, 0) # Some text: mlab.text(0.01, 0.8, axis_name, width=0.08) # Choose a view that makes sens views = dict(x=(0, 0), y=(90, 180), z=(0, 0)) mlab.view(views[axis_name][0], views[axis_name][1], focalpoint=0.5*np.array(self.data.shape), figure=scene.mayavi_scene) scene.scene.camera.parallel_scale = 0.52*np.mean(self.data.shape) ``` -------------------------------- ### Run Offscreen Example Source: https://docs.enthought.com/mayavi/mayavi/auto/example_offscreen.html Command to execute the offscreen rendering script from the terminal. ```bash $ python offscreen.py ```