

.. _example_gallery:

Example gallery
=================


Mlab functions gallery
----------------------

These are the examples of the mlab plotting functions. They are
copied out here for convenience. Please refer to the corresponding
section of the user guide for more information (
:ref:`mlab_plotting_functions`).

.. currentmodule:: enthought.mayavi.mlab

+------------------+-------------------------+---------------------+
| :func:`plot3d`   | :func:`points3d`        | :func:`imshow`      |
|                  |                         |                     |
| |plot3d.jpg|     | |points3d.jpg|          | |imshow.jpg|        |
+------------------+-------------------------+---------------------+
| :func:`surf`     | :func:`contour_surf`    | :func:`mesh`        |
|                  |                         |                     |
| |surf.jpg|       | |contour_surf.jpg|      | |mesh.jpg|          |
+------------------+-------------------------+---------------------+
| :func:`barchart` | :func:`triangular_mesh` | :func:`contour3d`   |
|                  |                         |                     |
| |barchart.jpg|   | |triangular_mesh.jpg|   | |contour3d.jpg|     |
+------------------+-------------------------+---------------------+
| :func:`quiver3d` | :func:`flow`            |                     |
|                  |                         |                     |
| |quiver3d.jpg|   |  |flow.jpg|             |                     |
+------------------+-------------------------+---------------------+

.. |plot3d.jpg| image:: ../generated_images/enthought_mayavi_mlab_plot3d.jpg
     :width: 150

.. |points3d.jpg| image:: ../generated_images/enthought_mayavi_mlab_points3d.jpg
     :width: 150

.. |imshow.jpg| image:: ../generated_images/enthought_mayavi_mlab_imshow.jpg
     :width: 150

.. |contour_surf.jpg| image:: ../generated_images/enthought_mayavi_mlab_contour_surf.jpg
     :width: 150

.. |triangular_mesh.jpg| image:: ../generated_images/enthought_mayavi_mlab_triangular_mesh.jpg
     :width: 150

.. |surf.jpg| image:: ../generated_images/enthought_mayavi_mlab_surf.jpg
     :width: 150

.. |mesh.jpg| image:: ../generated_images/enthought_mayavi_mlab_mesh.jpg
     :width: 150

.. |barchart.jpg| image:: ../generated_images/enthought_mayavi_mlab_barchart.jpg
     :width: 150

.. |contour3d.jpg| image:: ../generated_images/enthought_mayavi_mlab_contour3d.jpg
     :width: 150

.. |quiver3d.jpg| image:: ../generated_images/enthought_mayavi_mlab_quiver3d.jpg
     :width: 150

.. |flow.jpg| image:: ../generated_images/enthought_mayavi_mlab_flow.jpg
     :width: 150



Advanced mlab examples
-----------------------

.. toctree::
   :hidden:
    
   example_boy.rst
   example_julia_set.rst
   example_surface_from_irregular_data.rst
   example_canyon.rst
   example_lorenz.rst
   example_spherical_harmonics.rst
   example_tvtk_in_mayavi.rst
   example_atomic_orbital.rst
   example_julia_set_decimation.rst
   example_simple_structured_grid.rst
   example_chemistry.rst
   example_wigner.rst
   example_canyon_decimation.rst
   example_magnetic_field_lines.rst
   example_mri.rst
   example_protein.rst
   example_flight_graph.rst


.. |0000| image:: ../generated_images/example_boy.jpg
    :width: 150

            
.. |0001| image:: ../generated_images/example_julia_set.jpg
    :width: 150

            
.. |0002| image:: ../generated_images/example_surface_from_irregular_data.jpg
    :width: 150

            
.. |0003| image:: ../generated_images/example_canyon.jpg
    :width: 150

            
.. |0004| image:: ../generated_images/example_lorenz.jpg
    :width: 150

            
.. |0005| image:: ../generated_images/example_spherical_harmonics.jpg
    :width: 150

            
.. |0006| image:: ../generated_images/example_tvtk_in_mayavi.jpg
    :width: 150

            
.. |0007| image:: ../generated_images/example_atomic_orbital.jpg
    :width: 150

            
.. |0008| image:: ../generated_images/example_julia_set_decimation.jpg
    :width: 150

            
.. |0009| image:: ../generated_images/example_simple_structured_grid.jpg
    :width: 150

            
.. |0010| image:: ../generated_images/example_chemistry.jpg
    :width: 150

            
.. |0011| image:: ../generated_images/example_wigner.jpg
    :width: 150

            
.. |0012| image:: ../generated_images/example_canyon_decimation.jpg
    :width: 150

            
.. |0013| image:: ../generated_images/example_magnetic_field_lines.jpg
    :width: 150

            
.. |0014| image:: ../generated_images/example_mri.jpg
    :width: 150

            
.. |0015| image:: ../generated_images/example_protein.jpg
    :width: 150

            
.. |0016| image:: ../generated_images/example_flight_graph.jpg
    :width: 150

            
======= =============================================
======= =============================================
|0000|  :ref:`example_boy`
         A script to generate the Mayavi logo: a
         Boy surface.

|0001|  :ref:`example_julia_set`
         An example showing the Julia set
         displayed as a z-warped surface.

|0002|  :ref:`example_surface_from_irregular_data`
         An example which shows how to plot a
         surface from data acquired irregularly.

|0003|  :ref:`example_canyon`
         Retrieve radar data from the NASA and
         plot a view of the Grand Canyon
         landscape.

|0004|  :ref:`example_lorenz`
         An example displaying the trajectories
         for the Lorenz system of equations along
         with the z-nullcline.

|0005|  :ref:`example_spherical_harmonics`
         Plot spherical harmonics on the surface
         of the sphere, as well as a 3D polar
         plot.

|0006|  :ref:`example_tvtk_in_mayavi`
         An example of pure TVTK programming to
         build TVTK objects, which are then added
         to a Mayavi scene.

|0007|  :ref:`example_atomic_orbital`
         An example showing the norm and phase
         of an atomic orbital: isosurfaces of the
         norm, with colors  displaying the phase.

|0008|  :ref:`example_julia_set_decimation`
         The Julia set, but with a decimated
         mesh: unecessary triangles due to the
         initial grid and not matching the
         geometry of the Julia set are removed.

|0009|  :ref:`example_simple_structured_grid`
         An example creating a structured grid
         data set from numpy arrays using TVTK
         and visualizing it using mlab.

|0010|  :ref:`example_chemistry`
         In this example, we display the H2O
         molecule, and use volume rendering to
         display the electron localization
         function.

|0011|  :ref:`example_wigner`
         An example in which 3 functions of x
         and y  are displayed with a surf plot,
         while the z scaling is kept constant, to
         allow comparison between them.

|0012|  :ref:`example_canyon_decimation`
         Use the greedy-terrain-decimator to
         display a decimated terrain view.

|0013|  :ref:`example_magnetic_field_lines`
         This example uses the streamline module
         to display field lines of a magnetic
         dipole (a current loop).

|0014|  :ref:`example_mri`
         Viewing MRI data with cut plane and iso
         surface.

|0015|  :ref:`example_protein`
         Visualize a protein graph structure
         downloaded from the protein database in
         standard pdb format.

|0016|  :ref:`example_flight_graph`
         An example showing a graph display
         between cities positionned on the Earth
         surface.

======= =============================================

Interactive examples
--------------------------------------------------



Examples showing how to use the interactive features of Mayavi, either
via the mayavi2 application, or via specially-crafted dialogs and
applications.
    

.. toctree::
   :hidden:
    
   example_mlab_visual.rst
   example_mlab_traits_ui.rst
   example_wx_embedding.rst
   example_multiple_mlab_scene_models.rst
   example_multiple_engines.rst
   example_wx_mayavi_embed_in_notebook.rst
   example_mlab_interactive_dialog.rst
   example_subclassing_mayavi_application.rst
   example_mayavi_traits_ui.rst
   example_compute_in_thread.rst
   example_poll_file.rst
   example_lorenz_ui.rst
   example_volume_slicer.rst

.. A comment to split paragraphs


.. |0100| image:: ../images/example_mlab_visual.jpg
    :width: 150

            
.. |0101| raw:: html
    
    <br/>

            
.. |0102| raw:: html
    
    <br/>

            
.. |0103| raw:: html
    
    <br/>

            
.. |0104| raw:: html
    
    <br/>

            
.. |0105| raw:: html
    
    <br/>

            
.. |0106| image:: ../images/example_mlab_interactive_dialog.jpg
    :width: 150

            
.. |0107| raw:: html
    
    <br/>

            
.. |0108| raw:: html
    
    <br/>

            
.. |0109| raw:: html
    
    <br/>

            
.. |0110| raw:: html
    
    <br/>

            
.. |0111| raw:: html
    
    <br/>

            
.. |0112| raw:: html
    
    <br/>

            
======= =============================================
======= =============================================
|0100|  :ref:`example_mlab_visual`
         A very simple example to show how you
         can use TVTK's visual module with mlab
         and create simple animations.

|0101|  :ref:`example_mlab_traits_ui`
         A simple example of how to use
         mayavi.mlab inside a traits UI dialog.

|0102|  :ref:`example_wx_embedding`
         This example shows to embed a Mayavi
         view in a wx frame.

|0103|  :ref:`example_multiple_mlab_scene_models`
         Example showing a dialog with multiple
         embedded scenes.

|0104|  :ref:`example_multiple_engines`
         An example to show how you can have
         multiple engines in one application.

|0105|  :ref:`example_wx_mayavi_embed_in_notebook`
         This example show how to embedded
         Mayavi in a wx notebook.

|0106|  :ref:`example_mlab_interactive_dialog`
         An example of how to modify the data
         visualized  via an interactive dialog.

|0107|  :ref:`example_subclassing_mayavi_application`
         This script demonstrates how one can
         script Mayavi by subclassing the
         application, create a new VTK scene and
         create a few simple modules.

|0108|  :ref:`example_mayavi_traits_ui`
         An example of how to create an almost
         complete Mayavi UI inside a Traits UI
         view.

|0109|  :ref:`example_compute_in_thread`
         This script demonstrates how one can do
         a computation in another thread and
         update the mayavi pipeline. It also
         shows how to create a numpy array data
         and visualize it as image data using a
         few modules.

|0110|  :ref:`example_poll_file`
         A simple script that polls a data file
         for changes and then updates the mayavi
         pipeline automatically.

|0111|  :ref:`example_lorenz_ui`
         This example displays the trajectories
         for the Lorenz system of equations using
         mlab along with the z-nullcline.  It
         provides a simple UI where a user can
         change the parameters and the system of
         equations on the fly.  This primarily
         demonstrates how one can build powerful
         tools with a UI using Traits and Mayavi.

|0112|  :ref:`example_volume_slicer`
         Example of an elaborate dialog showing
         a multiple views on the same data, with
         3 cuts synchronized.

======= =============================================

Advanced visualization examples
--------------------------------------------------


Data visualization using the core Mayavi API, object-oriented, and with
more fine control than mlab.     

    

.. toctree::
   :hidden:
    
   example_polydata.rst
   example_offscreen.rst
   example_surf_regular_mlab.rst
   example_structured_points2d.rst
   example_glyph.rst
   example_contour_contour.rst
   example_scatter_plot.rst
   example_structured_points3d.rst
   example_streamline.rst
   example_numeric_source.rst
   example_contour.rst
   example_unstructured_grid.rst
   example_structured_grid.rst
   example_datasets.rst

.. A comment to split paragraphs


* :ref:`example_polydata`
    An example of how to generate a polydata dataset using numpy arrays.

* :ref:`example_offscreen`
    A simple example of how you can use Mayavi without using Envisage
    or the Mayavi Envisage application and do off screen rendering.

* :ref:`example_surf_regular_mlab`
    Shows how to view data created by `enthought.tvtk.tools.mlab` with
    mayavi2.

* :ref:`example_structured_points2d`
    An example of how to generate a 2D structured points dataset
    using numpy arrays.  Also shown is a way to visualize this data with
    the mayavi2 application.

* :ref:`example_glyph`
    This script demonstrates using the Mayavi core API to add a VectorCutPlane,
    split the pipeline using a MaskPoints filter and then view the filtered data
    with the Glyph module.

* :ref:`example_contour_contour`
    This example shows how you can produce contours on an IsoSurface.

* :ref:`example_scatter_plot`
    An example of plotting scatter points with Mayavi's core API.

* :ref:`example_structured_points3d`
    An example of how to generate a 3D structured points dataset
    using numpy arrays.  Also shown is a way to visualize this data with
    the mayavi2 application.

* :ref:`example_streamline`
    This script demonstrates how one can script Mayavi's core API to display
    streamlines and an iso surface.

* :ref:`example_numeric_source`
    This script demonstrates how to create a numpy array data and
    visualize it as image data using a few modules.

* :ref:`example_contour`
    This script demonstrates how one can script Mayavi and use its
    contour related modules.

* :ref:`example_unstructured_grid`
    A MayaVi example of how to generate an unstructured grid dataset
    using numpy arrays.  Also shown is a way to visualize this data with
    mayavi2.  The script can be run like so:

* :ref:`example_structured_grid`
    An example of how to generate a structured grid dataset using
    numpy arrays.  Also shown is a way to visualize this data with
    the mayavi2 application.

* :ref:`example_datasets`
    A Mayavi example to show the different data sets. See
    :ref:`data-structures-used-by-mayavi` for a discussion.

Misc examples
--------------------------------------------------



.. toctree::
   :hidden:
    
   example_standalone.rst
   example_zzz_reader.rst
   example_nongui.rst
   example_user_mayavi.rst

.. A comment to split paragraphs


* :ref:`example_standalone`
    A simple example of how you can use Mayavi without
    using Envisage or the Mayavi Envisage application.

* :ref:`example_zzz_reader`
    This is a simple example that shows how to create a reader factory
    and register that reader with mayavi.

* :ref:`example_nongui`
    This script demonstrates how one can use the Mayavi application framework
    without displaying Mayavi's UI.

* :ref:`example_user_mayavi`
    Sample Mayavi customization file.
