7.18 Color Scale Specifications

Color scales are used in PDP++ to display the values of variables graphically in various types of displays. The choice of color scale depends on personal preferences as well as what type of display the user has available. There are a number of different types of color scales that come with the software, and the user can create their own custom colorscales.

A color scale is specified by creating a set of different color points. The actual scale is just the linear interpolation between each of these points, where the points are distributed evenly through the range of values covered by the scale. Thus, if there were three such points in a color specification that goes from -1 to 1, the first point would represent the value -1, the middle one would represent 0, and the last one would represent 1. Values in between would be represented by intermediate colors between these points. The actual number of colors created in a given color scale is determined by the color_scale_size setting parameter for color displays, and mono_scale_size for monochrome displays (see section 7.17 Settings Affecting GUI Behavior).

The PDPRoot object contains a group of color specifications called .colorspecs, which is where the default color scales and any new ones the user creates are located. The default element (see section 8.2 Groups) of this group represents the default color scale to use when creating a new display that uses color scales. The defaults are as follows:

C_ColdHot
interpolates from violet->blue->grey>->red->yellow
C_BlueBlackRed
interpolates from blue->black-red
C_BlueGreyRed
interpolates from blue->grey->red
C_BlueWhiteRed
interpolates from blue->white->red
C_BlueGreenRed
interpolates from blue->green->red
C_Rainbow
interpolates from violet->blue->green->yellow->red
C_ROYGBIV
interpolates from violet->indigo->blue->green->yellow->red
C_DarkLight
interpolates from black->white
C_LightDark
interpolates from white->black
M_DarkLight
dithers from black->white
M_LightDark
dithers from white->black
M_LightDarkLight
dithers from white->black->white
P_DarkLight
dithers from black->white with a white background for printing
P_DarkLight_bright
dithers from black->white with a white background for printing, having a brighter overall tone than the basic one (a lighter zero value).
P_LightDark
dithers from white->black with a white background for printing
P_DarkLightDark
same as M_DarkLightDark with a white background for printing
P_LightDarkLight
same as M_LightDarkLight with a white background for printing

The ColorScaleSpec is the object that specifies the color scale. It contains a group of RGBA objects, each of which is used to specify a point on the colorscale range based on the Red, Green, and Blue values, plus a "transparency" parameter Alpha. The ColorScaleSpec object has one primary function.

GenRanges (ColorGroup* cl, int nper)
This function creates a range of colors in the ColorGroup by linearly interpolating nper colors for each RGBA set point value in the ColorScaleSpec.

The RGBA object has the following fields:

String name
The name of the color
float r
Amount of red in the color (0.0 - 1.0)
float g
Amount of green in the color (0.0 - 1.0)
float b
Amount of blue in the color (0.0 - 1.0)
float a
Alpha intensity value (ratio of foreground to background) This is used primarily for monochrome displays.

If the name field of an RGBA object is set, then it will try to lookup the name to find the r,g, and b values for that color.

Thus, to create your own color scale specification, just create a new ColorScaleSpec object, and then create some number of RGBA objects in it. Then, edit your views (e.g., the network view, @xref{net-view}), and set their colorspec to point to your new specification. In order to see changes you make to your color spec, you need to switch the colorspec pointer to a different one and then back to yours after making the changes.