FAQ

Palettes for out-of-bounds data

Palettes for out-of-bounds data

 
 

Question:

How can I create a palette to show out-of-bounds data?

We often want to use a "standard" color palette -- specific colors associated with specific data values -- but the data may occasionally go outside the range of thispreset palette. If so, we might like to use a distinct color (say gray) to color the out-of-range values.

Example:

yes? USE coads_climatology
yes? ! Define a variable with range outside the ocean temperature range
yes? LET svar = (1.6*sst) - 5 
yes? FILL/L=1/PALETTE=ocean_temp.spk/LEV=20 svar
yes? GO fland 60 black

 

Explanation:

 

(See the general FAQ on color palettes and the Users Guide for more on By_value color palettes.) Here is the color palette ocean_temp.spk, associating data values (in the first column) with colors:

RGB_Mapping By_value
 
! SetPt Red Green Blue
-2.0 80.0 0.0 100.0 ! violet
0.0 30.0 20.0 100.0 ! blue
10.0 0.0 60.0 30.0 ! green
20.0 100.0 100.0 0.0 ! yellow
30.0 100.0 0.0 0.0 ! red
35.0 60.0 0.0 0.0 ! dark red

When values of our variable are outside the range specified in the palette,they take on the first or last color of the palette. Instead, we would like to show those in an obviously different color, such as gray.

Solution:

 

Define a new palette, with one color of grey before the first value and a second gray after the last value (or one could use the same color). Here is ocean_temp_bounds.spk:

 

RGB_Mapping By_value
 
! SetPt Red Green Blue
-2.001 40.0 40.0 40.0 ! dark gray
-2.0 80.0 0.0 100.0 ! violet
0.0 30.0 20.0 100.0 ! blue
10.0 0.0 60.0 30.0 ! green
20.0 100.0 100.0 0.0 ! yellow
30.0 100.0 0.0 0.0 ! red
35.0 60.0 0.0 0.0 ! dark red
35.001 80.0 80.0 80.0 ! light gray
yes? FILL/L=1/PALETTE=ocean_temp_bounds.spk/LEV=20 svar
yes? GO fland 60 black

 

 

Or, use the /LEVELS qualifier with upper and lower indefinite levels for a nicer color bar

 

yes? FILL/L=1/PALETTE=ocean_temp_bounds.spk/LEV=(-inf),(-2,36,2)(inf) svar
yes? GO fland 60 black