Yorick: palette

Home Manual Packages Global Index Keywords Quick Reference |
### 3.2.4 palette The plf, pli, and plfp commands require a color scale or palette, which is a continuum of colors to represent the continuous values of a variable. Actually, a palette consists of a finite number of (red, green, blue) triples, which represent a color for each of a finite list of values. A Yorick palette can never have more than 256 colors, so that a type char variable (one byte per item) can hold any index into a palette. Because many screens can display only 256 colors simultaneously, however, you shouldn't have more than about 200 colors in a palette; that is the size of all of Yorick's predefined palettes. The palette command allows you to change palettes. The Yorick distribution comes with predefined palettes called ``earth.gp'` (the default palette), ``gray.gp'`, ``yarg.gp'`, ``heat.gp'`, ``stern.gp'`, and ``rainbow.gp'`. To load the gray palette, you would type:
    palette, "gray.gp"
These palettes tend to start with dark colors and progress toward lighter colors. The exceptions are ``yarg.gp'`, which is a reversed version of ``gray.gp'` (your picture looks like the photographic negative of the way it looks with the ``gray.gp'` palette), and ``rainbow.gp'`, which runs through the colors in spectral order at nearly constant intensity. Besides ``gray.gp'` (or ``yarg.gp'`) and ``rainbow.gp'`, it's tough to find color sequences that people have been trained to think have an order. The ``heat.gp'` palette is a red-orange scale resembling the colors of an iron bar as it grows hotter. The default ``earth.gp'` is loosely based on mapmaker's colors from dark blue deep ocean to green lowlands to brown highlands to white mountains. Instead of a file name, you may pass palette three arrays of numbers ranging from 0 to 255, which are relative intensities of red, green, and blue. For example,
    scale = bytscl(indgen(200),top=255);
    palette, scale,scale,scale;
produces the same palette as ``gray.gp'`, but by direct specification of RGB values, rather than by reading a palette file. Yorick internally uses the bytscl function to map the z values in a plf, pli, or plfp command into a (0-origin) index into the palette. Occasionally, as here, you will also want to call bytscl explicitly. The predefined palette files are in the directory `Y_SITE+"gist"`; you should be able to figure out their format easily if you want to produce your own. If you create a directory ``~/Gist'` and put your custom palette files there, Yorick will find them no matter what its current working directory. The library include file ``color.i'` includes functions to help you construct palettes, and a dump_palette function which writes a palette in Yorick's standard format. You can use the `query=` keyword to retrieve the RGB values for the currently installed palette:
    local r,g,b;
    palette,query=1, r,g,b;
There is also a `private=` keyword to palette, which you should investigate if you are interested in color table animation, or if other programs steal all your colors.