|MATLAB Function Reference|
Set and get the current colormap
A colormap is an m-by-3 matrix of real numbers between 0.0 and 1.0. Each row is an RGB vector that defines one color. The kth row of the colormap defines the kth color, where
b(k)]) specifies the intensity of red, green, and blue.
sets the colormap to the matrix
map. If any values in
map are outside the interval [0 1], MATLAB returns the error
Colormap must have values in [0,1].
sets the current colormap to the default colormap.
cmap = colormap
retrieves the current colormap. The values returned are in the interval [0 1].
M-files in the
color directory generate a number of colormaps. Each M-file accepts the colormap size as an argument. For example,
hsv colormap with 128 colors. If you do not specify a size, MATLAB creates a colormap the same size as the current colormap.
MATLAB supports a number of built-in colormaps, illustrated and described below. In addition to specifying built-in colormaps programmatically, you can use the Colormap menu in the Figure Properties pane of the Plot Tools GUI to select one interactively.
The named built-in colormaps are the following:
autumnvaries smoothly from red, through orange, to yellow.
boneis a grayscale colormap with a higher value for the blue component. This colormap is useful for adding an "electronic" look to grayscale images.
colorcubecontains as many regularly spaced colors in RGB colorspace as possible, while attempting to provide more steps of gray, pure red, pure green, and pure blue.
coolconsists of colors that are shades of cyan and magenta. It varies smoothly from cyan to magenta.
coppervaries smoothly from black to bright copper.
flagconsists of the colors red, white, blue, and black. This colormap completely changes color with each index increment.
grayreturns a linear grayscale colormap.
hotvaries smoothly from black through shades of red, orange, and yellow, to white.
hsvvaries the hue component of the hue-saturation-value color model. The colors begin with red, pass through yellow, green, cyan, blue, magenta, and return to red. The colormap is particularly appropriate for displaying periodic functions.
hsv(m)is the same as
his the linear ramp,
h = (0:m-1)'/m.
jetranges from blue to red, and passes through the colors cyan, yellow, and orange. It is a variation of the
jetcolormap is associated with an astrophysical fluid jet simulation from the National Center for Supercomputer Applications. See the "Examples" section.
linesproduces a colormap of colors specified by the axes
ColorOrderproperty and a shade of gray.
pinkcontains pastel shades of pink. The pink colormap provides sepia tone colorization of grayscale photographs.
prismrepeats the six colors red, orange, yellow, green, blue, and violet.
springconsists of colors that are shades of magenta and yellow.
summerconsists of colors that are shades of green and yellow.
whiteis an all white monochrome colormap.
winterconsists of colors that are shades of blue and green.
The images and colormaps demo,
imagedemo, provides an introduction to colormaps. Select Color Spiral from the menu. This uses the
pcolor function to display a 16-by-16 matrix whose elements vary from 0 to 255 in a rectilinear spiral. The
hsv colormap starts with red in the center, then passes through yellow, green, cyan, blue, and magenta before returning to red at the outside end of the spiral. Selecting Colormap Menu gives access to a number of other colormaps.
rgbplot function plots colormap values. Try
The following commands display the
flujet data using the
demos directory contains a CAT scan image of a human spine. To view the image, type the following commands:
image(X) colormap bone
Each figure has its own
colormap is an M-file that sets and gets this property.
Colormap property of figure graphics objects
Color Operations for related functions
Coloring Mesh and Surface Plots for more information about colormaps and other coloring methods
© 1994-2005 The MathWorks, Inc.