What are color maps and how are they structured?
VCS knows how to plot colors based upon color maps.
There aren't that many pre-defined color maps (the
show
command will list
all available maps in memory), so you might have to make your own:
>>> import vcs
>>> v = vcs.init()
>>> my_cm = v.createcolormap('my_cm', 'default')
my_cm
is a copy of the default color map.
Color maps are made of a dictionary of 256 colors. Each key (the "color index") in the dictionary is an integer from 0 to 255 [1]. Each color index refers to a 3-element list or tuple that gives the R, G, B values for the color referred to by that color index. The RGB values are given as percentages of intensity, and are integers from 0 to 100 (0 being lowest intensity and 100 being highest).
Color indices 240 to 255 are the same for every color map and are not changeable by the user; these indices correspond to the following RGB tuples (color names, unless obvious, are my guess from looking at the color on my screen):
Color Index | Color Name | RGB Tuple |
---|---|---|
240 | White | (100, 100, 100) |
241 | Black | (0, 0, 0) |
242 | Red | (100, 0, 0) |
243 | Green | (0, 100, 0) |
244 | Blue | (0, 0, 100) |
245 | Yellow | (100, 100, 0) |
246 | Turquoise | (0, 100, 100) |
247 | Magenta | (100, 0, 100) |
248 | Orange | (100, 50, 10) |
249 | Brown | (60, 30, 10) |
250 | A Blue of Some Sort | (5, 10, 67) |
251 | A Kind of Olive Brown | (50, 50, 0) |
252 | A Very Light Gray | (80, 80, 80) |
253 | A Very Very Light Green-Blue |
(80, 100, 80) |
254 | Light Pink | (95, 75, 75) |
255 | Light Blue | (60, 80, 100) |
Color indices 0 to 239 are user changable.
For instance, the following command makes
color index 3 refer to brown in color map my_cm
:
>>> my_cm.index[3] = [60, 30, 10]
The attribute index
is the dictionary of
the 3-element RGB lists/tuples.
To set the value of a color index in the active
color map, use the setcolorcell
method:
>>> v.setcolorcell(3, 60, 30, 10)
which sets color index 3 to brown (RGB values of [60, 30, 10]) in the active color map. Tips on creating and using a custom color map can be found here.
Footnotes:
[1]: All index ranges in this web page are inclusive unless otherwise noted. [Back to text]
Notes: This discussion applies to CDAT 3.3.