1
Changing the looks of the visual objects created
2
-------------------------------------------------
4
Adding color or size variations
5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8
The color of the objects created by a plotting function can be specified
9
explicitly using the 'color' keyword argument of the function. This color
10
is than applied uniformly to all the objects created.
12
If you want to vary the color across your visualization, you need to
13
specify scalar information for each data point. Some functions try to
14
guess this information: these scalars default to the norm of the vectors,
15
for functions with vectors, or to the z elevation for functions where is
16
meaningful, such as :func:`surf` or :func:`barchart`.
18
This scalar information is converted into colors using the colormap, or
19
also called LUT, for Look Up Table. The list of possible colormaps is::
21
accent flag hot pubu set2
22
autumn gist_earth hsv pubugn set3
23
black-white gist_gray jet puor spectral
24
blue-red gist_heat oranges purd spring
25
blues gist_ncar orrd purples summer
26
bone gist_rainbow paired rdbu winter
27
brbg gist_stern pastel1 rdgy ylgnbu
28
bugn gist_yarg pastel2 rdpu ylgn
29
bupu gnbu pink rdylbu ylorbr
30
cool gray piyg rdylgn ylorrd
31
copper greens prgn reds
32
dark2 greys prism set1
34
The easiest way to choose the colormap most adapted to your visualization
35
is to use the GUI (as described in the next paragraph). The dialog
36
to set the colormap can be found in the `Colors and legends` node.
39
The scalar information can also be displayed in many different ways.
40
For instance it can be used to adjust the size of glyphs positioned at
43
**A caveat: Clamping: relative or absolute scaling**
44
Given six points positionned on a line with interpoint spacing 1::
46
x = [1, 2, 3, 4, 5, 6]
47
y = [0, 0, 0, 0, 0, 0]
50
If we represent a scalar varying from 0.5 to 1 on this dataset::
52
s = [.5, .6, .7, .8, .9, 1]
54
We represent the dataset as spheres, using :func:`points3d`, and the
55
scalar is mapped to diameter of the spheres::
57
from enthought.mayavi import mlab
58
pts = mlab.points3d(x, y, z, s)
60
By default the diameter of the spheres is not 'clamped', in other
61
words, the smallest value of the scalar data is represented as a null
62
diameter, and the largest is proportional to inter-point distance.
63
The scaling is only relative, as can be seen on the resulting
66
.. image:: clamping_on.jpg
68
This behavior gives visible points for all datasets, but may not be
69
desired if the scalar represents the size of the glyphs in the same
70
unit as the positions specified.
72
In this case, you shoud turn auto-scaling off by specifying the desired
75
pts = mlab.points3d(x, y, z, s, scale_factor=1)
77
.. image:: clamping_off.jpg
81
In earlier versions of Mayavi (up to 3.1.0 included), the glyphs are
82
not auto-scaled, and as a result the visualization can seem empty
83
due to the glyphs being very small. In addition the minimum diameter of
84
the glyphs is clamped to zero, and thus the glyph are not scaled
85
absolutely, unless you specifie::
87
pts.glyph.glyph.clamping = False
89
:More representations of the attached scalars or vectors:
90
There are many more ways to represent the scalar or vector information
91
attached to the data. For instance, scalar data can be 'warped' into a
92
displacement, e.g. using a `WarpScalar` filter, or the norm of scalar
93
data can be extract to a scalar component that can be visualized using
94
iso-surfaces with the `ExtractVectorNorm` filter.
97
Changing the scale and position of objects
98
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100
Each mlab function takes an `extent` keyword argument, that allows to set
101
its (x, y, z) extents. This give both control on the scaling in the
102
different directions and the displacement of the center. Beware that when
103
you are using this functionality, it can be useful to pass the same
104
extents to other modules visualizing the same data. If you don't, they
105
will not share the same displacement and scale.
107
.. _mlab-changing-objects-interactively:
109
Changing object properties interactively
110
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
112
Mayavi, and thus mlab, allows you to interactively modify your
115
The Mayavi pipeline tree can be displayed by clicking on the mayavi icon
116
in the figure's toolbar, or by using :func:`show_pipeline` mlab command.
117
One can now change the visualization using this dialog by double-clicking
118
on each object to edit its properties, as described in other parts of
119
this manual, or add new modules or filters by using this icons on the
120
pipeline, or through the right-click menus on the objects in the
123
.. image:: images/pipeline_and_scene.png
125
In addition, for every object returned by a mlab function,
126
``this_object.edit_traits()`` brings up a dialog that can be used to
127
interactively edit the object's properties. If the dialog doesn't show up
128
when you enter this command, please see :ref:`running-mlab-scripts`.
134
indent-tabs-mode: nil
135
sentence-end-double-space: t