Hi Herbert,

On Fri, Jan 14, 2011 at 03:22:55PM -0600, Herbert Pablo wrote:
>    What I would like to do is plot a sphere with one main color and
>    then have circular regions on the surface which are a different
>    color. I'm sure that this is possible by defining a 4th array which
>    has different numbers for the regions that I want a different color.
>    There are already colormaps in place, but I want specific colors for
>    these different regions and so I thought about making my own
>    colormap, but I can't figure out. There is a small tutorial I found
>    that allowed you to change an existing color map, but that doesn't
>    have enough information for me to create my own.

I guess that you are talking about the following example:

http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/example_custom_colormap.html

>     I looked in the package and then I noticed that the colormaps are
>     gif files so I am a little bit stumped.

The gif files are just representations of the predefined colormaps that
are used in the user interface. They do no specify them.

>     How do I say�something like any time value x comes up that region
>     should be yellow and anytime value y comes up that region should be
>     black?

The colormaps (or look up tables -LUT- in VTK speach) are defined for
values in the 0-1 range. The first thing that Mayavi will do is to
rescale your scalar data so that it fits in the 0-1 range. If you give
the functions a vmin or vmax argument, it will scale the corresponding
range to the 0-1 interval.

So, if you want to have exact control on what gets displayed where, the
easiest is to create a scalar arrays, the histogram of which is made of
'n' values regularly spaced between 0 and 1. 

Then, you can tune the number of entries in the look up table using the
'number_of_colors' attribute of the lut object. For example, using the
same names than the custom_colormap example:

surf.module_manager.scalar_lut_manager.lut.number_of_colors = 10

Finally, all you have to do is assign an array of the right shape, i.e.
(n_colors, 4), to the 'table attribute:

surf.module_manager.scalar_lut_manager.lut.table = array

HTH,

Gael


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
MayaVi-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mayavi-users

Reply via email to