~ubuntu-branches/debian/sid/mayavi2/sid

« back to all changes in this revision

Viewing changes to docs/source/mayavi/mlab_changing_object_looks.rst

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2009-03-27 04:34:55 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090327043455-vs6ox32daj6ndw33
Tags: 3.2.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Changing the looks of the visual objects created
 
2
-------------------------------------------------
 
3
 
 
4
Adding color or size variations
 
5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
6
 
 
7
:Color:
 
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. 
 
11
 
 
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`.
 
17
 
 
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::
 
20
 
 
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
 
33
 
 
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.
 
37
 
 
38
:Size of the glyph:
 
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 
 
41
  the data points. 
 
42
 
 
43
  **A caveat: Clamping: relative or absolute scaling**
 
44
  Given six points positionned on a line with interpoint spacing 1::
 
45
 
 
46
    x = [1, 2, 3, 4, 5, 6]
 
47
    y = [0, 0, 0, 0, 0, 0]
 
48
    z = y
 
49
 
 
50
  If we represent a scalar varying from 0.5 to 1 on this dataset::
 
51
 
 
52
    s = [.5, .6, .7, .8, .9, 1]
 
53
 
 
54
  We represent the dataset as spheres, using :func:`points3d`, and the 
 
55
  scalar is mapped to diameter of the spheres::
 
56
 
 
57
    from enthought.mayavi import mlab
 
58
    pts = mlab.points3d(x, y, z, s)
 
59
 
 
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
 
64
  figure:
 
65
 
 
66
  .. image:: clamping_on.jpg
 
67
 
 
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.
 
71
 
 
72
  In this case, you shoud turn auto-scaling off by specifying the desired
 
73
  scale factor::
 
74
 
 
75
    pts = mlab.points3d(x, y, z, s, scale_factor=1)
 
76
 
 
77
  .. image:: clamping_off.jpg
 
78
 
 
79
  .. warning:: 
 
80
    
 
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::
 
86
 
 
87
        pts.glyph.glyph.clamping = False
 
88
 
 
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.
 
95
 
 
96
 
 
97
Changing the scale and position of objects
 
98
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
99
 
 
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.
 
106
 
 
107
.. _mlab-changing-objects-interactively:
 
108
 
 
109
Changing object properties interactively
 
110
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
111
 
 
112
Mayavi, and thus mlab, allows you to interactively modify your
 
113
visualization.
 
114
 
 
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
 
121
pipeline.
 
122
 
 
123
.. image:: images/pipeline_and_scene.png
 
124
 
 
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`.
 
129
 
 
130
 
 
131
..
 
132
   Local Variables:
 
133
   mode: rst
 
134
   indent-tabs-mode: nil
 
135
   sentence-end-double-space: t
 
136
   fill-column: 70
 
137
   End:
 
138