File: examples.rst

package info (click to toggle)
mayavi2 4.8.3-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 21,892 kB
  • sloc: python: 49,447; javascript: 32,885; makefile: 129; fortran: 60
file content (702 lines) | stat: -rw-r--r-- 19,440 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702


.. _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:: 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_julia_set.rst
   example_boy.rst
   example_bunny.rst
   example_dragon.rst
   example_lucy.rst
   example_custom_colormap.rst
   example_surface_from_irregular_data.rst
   example_spherical_harmonics.rst
   example_lorenz.rst
   example_canyon.rst
   example_julia_set_decimation.rst
   example_simple_structured_grid.rst
   example_atomic_orbital.rst
   example_tvtk_in_mayavi.rst
   example_chemistry.rst
   example_wigner.rst
   example_canyon_decimation.rst
   example_plotting_many_lines.rst
   example_magnetic_field_lines.rst
   example_mri.rst
   example_protein.rst
   example_flight_graph.rst


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

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

            
.. |0002| raw:: html

    <br/>

            
.. |0003| raw:: html

    <br/>

            
.. |0004| raw:: html

    <br/>

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

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

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

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

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

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

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

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

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

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

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

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

            
.. |0017| image:: ../generated_images/example_plotting_many_lines.jpg
    :width: 150

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

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

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

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

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

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

|0002|  :ref:`example_bunny`
         Viewing Stanford 3D Scanning Repository
         bunny model

|0003|  :ref:`example_dragon`
         Viewing Stanford 3D Scanning Repository
         dragon model

|0004|  :ref:`example_lucy`
         Viewing Stanford 3D Scanning Repository
         lucy model

|0005|  :ref:`example_custom_colormap`
         An example showing how a custom
         colormap (or look up table) can be used
         for a given object.

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

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

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

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

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

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

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

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

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

|0015|  :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.

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

|0017|  :ref:`example_plotting_many_lines`
         This examples shows how many lines can
         be grouped together in a single object,
         for convenience and efficiency.

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

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

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

|0021|  :ref:`example_flight_graph`
         An example showing a graph display
         between cities positioned 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_engines.rst
   example_multiple_mlab_scene_models.rst
   example_superquad_with_gui.rst
   example_mlab_interactive_dialog.rst
   example_wx_mayavi_embed_in_notebook.rst
   example_subclassing_mayavi_application.rst
   example_mayavi_traits_ui.rst
   example_compute_in_thread.rst
   example_qt_embedding.rst
   example_adjust_cropping_extents.rst
   example_poll_file.rst
   example_lorenz_ui.rst
   example_volume_slicer.rst
   example_coil_design_application.rst
   example_volume_slicer_advanced.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.png
    :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/>

            
.. |0113| raw:: html

    <br/>

            
.. |0114| raw:: html

    <br/>

            
.. |0115| raw:: html

    <br/>

            
.. |0116| raw:: html

    <br/>

            
.. |0117| 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_engines`
         An example to show how you can have
         multiple engines in one application.

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

|0105|  :ref:`example_superquad_with_gui`
         This example uses MayaVi to show the
         evolution of a superquadric (http://en.w
         ikipedia.org/wiki/Superquadrics), which
         are ellipsoidal surfaces parametrised by
         two parameters,lpha and eta. The
         equations that are used to determine the
         superquadric are (in spherical-polar
         coordinates):

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

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

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

|0109|  :ref:`example_mayavi_traits_ui`
         An example of how to create a UI
         similar to the complete Mayavi
         application inside a Traits UI view.

|0110|  :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.

|0111|  :ref:`example_qt_embedding`
         This example demonstrates using Mayavi
         as a component of a large Qt
         application.

|0112|  :ref:`example_adjust_cropping_extents`
         A custom dialog to adjust the
         parameters of a GeometryFilter to crop
         data points.

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

|0114|  :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.

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

|0116|  :ref:`example_coil_design_application`
         An full-blown application demoing a
         domain-specific usecase with Mayavi:
         interactive design of coils.

|0117|  :ref:`example_volume_slicer_advanced`
         An efficient implementation of the
         triple-plane view showing 3 cut planes
         on volumetric data, and side views
         showing each cut, with a cursor to move
         the other cuts.

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

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_glyph.rst
   example_structured_points2d.rst
   example_contour_contour.rst
   example_scatter_plot.rst
   example_streamline.rst
   example_numeric_source.rst
   example_structured_points3d.rst
   example_image_cursor_filter.rst
   example_contour.rst
   example_probe_filter.rst
   example_unstructured_grid.rst
   example_structured_grid.rst
   example_tvtk_segmentation.rst
   example_datasets.rst
   example_delaunay_graph.rst
   example_mlab_3D_to_2D.rst
   example_magnetic_field.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 `tvtk.tools.mlab` with
    mayavi2.

* :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_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_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_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_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_image_cursor_filter`
    Excample using the UserDefined filter to paint a cross-shaped cursor on data,
    in order to point out a special position.

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

* :ref:`example_probe_filter`
    Using the probe filter to visualize a scalar field along an arbitrary
    surface.

* :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_tvtk_segmentation`
    Using VTK to assemble a pipeline for segmenting MRI images. This example
    shows how to insert well-controled custom VTK filters in Mayavi.

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

* :ref:`example_delaunay_graph`
    An example illustrating graph manipulation and display with Mayavi
    and NetworkX.

* :ref:`example_mlab_3D_to_2D`
    A script to calculate the projection of 3D world coordinates to
    2D display coordinates (pixel coordinates) for a given scene.

* :ref:`example_magnetic_field`
    An example mixing numerical caculation and 3D visualization of the
    magnetic field created by an arbitrary number of current loops.

Data interaction examples
--------------------------------------------------


Examples showing how you can query and interact with the data.

    

.. toctree::
   :hidden:

   example_pick_on_surface.rst
   example_select_red_balls.rst

.. A comment to split paragraphs


* :ref:`example_pick_on_surface`
    Example showing how to pick data on a surface, going all the way back
    to the index in the numpy arrays.

* :ref:`example_select_red_balls`
    This example shows how to use a callback to select a red ball amongst white
    balls.

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.