Using Color in PV-WAVE
All PV‑WAVE graphics make use of colortables. A colortable is a collection of 256 colors, each referenced by an index (0-255). PV‑WAVE provides 19 predefined colortables and the user can define additional colortables. A single colortable may be used at any one time. To see the list of colortables available enter the command LOADCT. Once a table is selected, the COLOR_PALETTE command will display the current colortable and its indices. For example:
LOADCT, 18
COLOR_PALETTE
By default, the Black and White Linear colortable is loaded (colortable number 0). PV‑WAVE graphics come in two general types, raster and vector.
*Raster graphics refer to graphics that are produced by displaying bitmaps. Examples of PV‑WAVE raster (or bitmap) graphics routines are TV and IMAGE_DISPLAY. The inputs to these routines are simply arrays of pixel values that are mapped to the screen through the current colortable.
*Vector graphics refer to graphics that are produced by displaying lines and polygons based upon geometrical formulas or relationships between data. Examples of PV‑WAVE vector graphics routines are PLOT, CONTOUR, and vtkSURFACE.
PV‑WAVE raster graphics procedures typically do not have any inputs for color arguments; “color” happens by default in that the bitmap arrays are automatically mapped through the current colortable. For example, consider the differences between the following calls to TV:
img = DIST(360)
LOADCT, 0
WINDOW, XSize=360, YSize=360
TV, img
LOADCT, 18
TV, img
Since two different color tables were loaded the images display the same data with different colors.
PV‑WAVE vector graphics procedures typically have optional color arguments, often in the form of the Color keyword to the given procedure. By default, these procedures color the background graphics using the color associated with element 0 of the current colortable, and the foreground (lines, polygons, axes, etc.) is colored using the color associated with element 255.
For example, consider the difference between the following calls to PLOT:
x = INDGEN(10)
LOADCT, 0
COLOR_PALETTE
; In colortable 0, index 0 is black and 255 is white. When you
; create a plot, the background uses the color at index 0, and the 
; lines of the plot use the color at index 255.
WINDOW, /Free, Title='0 is Black, 255 is White'
PLOT, x
LOADCT, 16
COLOR_PALETTE
; In colortable 16, index 0 is white and 255 is black. As a 
; result the colors in the plot are now reversed.
WINDOW, /Free, Title='0 is White, 255 is Black'
PLOT, x
The Color keyword to PLOT however can change the default behavior. For example:
LOADCT, 0
TEK_COLOR
COLOR_PALETTE
WINDOW, /Free
PLOT, x, Color=WoColorConvert(2)
The COLOR_PALETTE window shows that element 2 of the current colortable is associated with red, and by using PLOT’s Color keyword with the argument of 2 the plot foreground is red rather than the default white.
 
note
Where color is used in this tutorial the TEK_COLOR procedure and the WoColorConvert function are used to ensure colors appear consistently whether on an older 8-bit or newer 24-bit graphical display:
*TEK_COLOR loads 32 predefined, unique, highly saturated colors into the bottom 32 indices of the current colortable (0–31).
*WoColorConvert converts colortable indices such that the colortable is referenced consistently on 8-bit and 24-bit graphical displays.