Prabhu Ramachandran | 1 Dec 2008 10:33
Picon
Gravatar

Re: Specifying colors for a mesh

Hi Anne,

Anne Archibald wrote:
> This seems like a terribly obvious question, but I have had no luck
> finding instructions on how to do it in the documentation:
> 
> Can I specify my own colors for a mesh? That is, I have an RGB value
> for each point. The color= keyword argument appears to require
> specifically a single tuple.

Thats the way it currently works unfortunately.  It is possible to 
specify scalars as RGB colors by specifying a 3 component unsigned char 
array with the rgb values (each in the range [0, 255]).  But this 
feature of VTK hasn't been exploited by us in mlab/mayavi.  We tend to 
treat scalars as a single dimensional array and use a suitable LUT to do 
the coloring.

> If this is for some reason impossible, can I supply my own colormap?

Yes indeed.  If none of the standard luts are good enough, there is a 
color editor that lets you generate your own lut files.  To run it try this:

#!/usr/bin/env python
from enthought.tvtk.util.wx_gradient_editor import main
main()

Then use the resulting .lut file for your colormap.

> In fact the colors are obtained from temperatures using a blackbody
> curve, so I could easily produce a look-up table to use. But it
(Continue reading)


Gmane