Reference Guide > Graphics and Plotting Keywords > Color Keyword
  

Color Keyword
Used With Routines:   AXIS,   BAR3D,   CONTOUR,   CONTOURFS,   CONTOUR2,   OPLOT,   PIE_CHART,   PLOTPLOTSPOLYFILLSHADE_SURF,   SHADE_SURF_IRR,   SURFACE,   XYOUTS
Corresponding System Variable:   !P.Color
Sets the color index of text, lines, solid polygon fill, data, axes, and annotation. If this keyword is omitted, !P.Color specifies the color index.
When used with PLOT, OPLOT, and PLOTS, the Color keyword can specify an array of color values. If an array is used, each color value in the array is applied, in order, to color the line segments and/or plot symbols that make up the graph. The colors are repeated, as needed, to complete the entire graph of the data set. In addition, when an array is specified, the !P.Color system variable is used to color the axes (rather than using one of the data colors). Negative values in a Color array create transparent data segments (in other words, no line segment is drawn for that data interval).
When used with PIE_CHART, you can only specify an array value for this keyword. The specified colors are applied, in order, to slices of pie chart.
 
note
You cannot specify an array of values for the !P.Color system variable. The array of color values can only be used with the Color keyword.
Example 1
This example draws axes in color 10. 9 line segments are drawn in colors 2, 3, 5, 2, 3, 5, 2, 3, 5.
TEK_COLOR
!P.Color = WoColorConvert(10)
PLOT, FINDGEN(10), Color=WoColorConvert([2,3,5])
Example 2
Plot data containing “missing” values by using the fact that negative colors are “transparent”.
; Flag some data as "missing" (= -1).
data = HANNING(50)
data([5, 6, 10, 20, 25, 30, 31]) = -1
; Normal plot with lots of spikes.
PLOT, data, PSym=-5, YRange=[0, 1]
; Array of plot colors.
col = REPLICATE(!P.Color, 50)
; Indices of missing points.
missing = WHERE(data EQ -1)
; Symbols on and line segments are transparent.
col(missing) = -1
; Draw plot symbols.
PLOT, data, PSym=5, YRange=[0, 1], Color=WoColorConvert(col)
; Line segments to left of missing points are also transparent.
col(missing-1) = -1
; Overlay lines with segments missing.
OPLOT, data, Color=WoColorConvert(col)

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.