COLORTABLE

With the COLORTABLE function, you can specify the parameters to create a custom color table or load a system color table with specified parameters.

Example

The following lines create the graphic shown at the top of this topic.

; Define the color table

levels = 10

ctable = COLORTABLE([[085,026,139],[135,206,255],[0,255,0]], NCOLORS = levels, /TRANSPOSE)

 

; Define the data

file = FILE_WHICH('elevbin.dat')

dem = READ_BINARY(file, DATA_DIMS = [64,64])

 

; Display the data.

c1 = CONTOUR(dem, $

C_COLOR = ctable, $

N_LEVELS = levels, $

/FILL, $

PLANAR = 0, $

TITLE = 'Santa Monica Mountains')

 

; Add the colorbar.

cbar = COLORBAR(TARGET = c1, ORIENTATION = 1, $

POSITION = [0.90, 0.2, 0.95, 0.75])

 

; Move the Z Axis to the back.

(c1['zaxis']).location = [0, (c1.yrange)[1], 0]

Syntax

table = COLORTABLE(COLOR [, BACKGROUND=value] [, GET_NAMES=value] [, INDICES=value] [, NCOLORS=value] [, /REVERSE] [, STRETCH=value] [, /TRANSPOSE])

Return Value

The COLORTABLE function returns a reference to the NCOLORS array: [NCOLORS, 3] or [3, NCOLORS] if the TRANSPOSE keyword is set.

If COLORTABLE fails to load a color table, then -1 is returned. !NULL is returned if the NULL keyword is set.

Arguments

COLOR

A byte or string referencing a color table or a byte/string array of colors. If color is not present then COLORTABLE() prints the available color tables with their index.

Keywords

BACKGROUND

Set this keyword to a string or three-element array describing the colors of the table. Default value is [0, 0, 0].

GET_NAMES

Set this keyword to a named variable that will capture the available color table names.

INDICES

An array of indices that specifies the location of each color in the table. The array should contain the same number of elements as the number of colors specified in the COLOR argument. The default is to take an even sample over NCOLORS.

NCOLORS

Set this keyword to the number of colors to display in the color table. The default value is 256.

REVERSE

Set this keyword to reverse the color table before returning the COLORTABLE value.

STRETCH

Set this keyword to a value between -100 and 100. This stretch is an array of offsets that describe the skew of each color segment. A negative stretch increases the lower index color's position. A positive stretch increases the higher index color's position. This value should contain one fewer elements than the number of colors that the COLOR argument defines.

TRANSPOSE

Set this keyword to transpose the color table before returning.

Version History

8.2.1

Introduced

See Also

!COLOR, IMAGE, SURFACE, COLORBAR, CONTOUR, Using IDL graphics, Loading a Default Color Table