Navigation

Operators and Keywords

Function List:

C++ API

: cmap = colormap ()
: cmap = colormap (map)
: cmap = colormap ("default")
: cmap = colormap (map_name)
: cmap = colormap (hax, …)
: colormap map_name

Query or set the current colormap.

With no input arguments, colormap returns the current color map.

colormap (map) sets the current colormap to map. The colormap should be an n row by 3 column matrix. The columns contain red, green, and blue intensities respectively. All entries must be between 0 and 1 inclusive. The new colormap is returned.

colormap ("default") restores the default colormap (the viridis map with 64 entries). The default colormap is returned.

The map may also be specified by a string, map_name, which is the name of a function that returns a colormap.

If the first argument hax is an axes handle, then the colormap for the parent figure of hax is queried or set.

For convenience, it is also possible to use this function with the command form, colormap map_name.

The list of built-in colormaps is:

MapDescription
viridisdefault
jetcolormap traversing blue, cyan, green, yellow, red.
cubehelixcolormap traversing black, blue, green, red, white with increasing intensity.
hsvcyclic colormap traversing Hue, Saturation, Value space.
rainbowcolormap traversing red, yellow, blue, green, violet.
————-———————————————————————————————
hotcolormap traversing black, red, orange, yellow, white.
coolcolormap traversing cyan, purple, magenta.
springcolormap traversing magenta to yellow.
summercolormap traversing green to yellow.
autumncolormap traversing red, orange, yellow.
wintercolormap traversing blue to green.
————-———————————————————————————————
graycolormap traversing black to white in shades of gray.
bonecolormap traversing black, gray-blue, white.
coppercolormap traversing black to light copper.
pinkcolormap traversing black, gray-pink, white.
oceancolormap traversing black, dark-blue, white.
————-———————————————————————————————
colorcubeequally spaced colors in RGB color space.
flagcyclic 4-color map of red, white, blue, black.
linescyclic colormap with colors from axes "ColorOrder" property.
prismcyclic 6-color map of red, orange, yellow, green, blue, violet.
————-———————————————————————————————
whiteall white colormap (no colors).

See also: viridis, jet, cubehelix, hsv, rainbow, hot, cool, spring, summer, autumn, winter, gray, bone, copper, pink, ocean, colorcube, flag, lines, prism, white.

Demonstration 1

The following code

 ## Create an image for displaying a colormap
 image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
 axis ([1, 64, 0, 1], "ticy", "xy");
 ## Show 'viridis' colormap
 colormap (viridis (64));
 title "colormap (viridis (64))"
 disp ("Press a key to continue");
 pause ();
 ## Show 'colorcube' colormap
 colormap (colorcube (64));
 title "colormap (colorcube (64))"

Produces the following output

Press a key to continue

and the following figure

Figure 1

Package: octave