colormap

Gets or sets the colormap, the table that turns data values into colors.

Category: Graphics > Formatting and Annotation

Syntax

colormap(map)

Sets the colormap of the current axes from an RGB matrix.

colormap(name)

Sets a named map such as 'hot', 'gray', 'parula', 'jet'.

map = colormap

Returns the current colormap.

colormap(ax, ___)

Applies to the axes ax.

Description

Plots that color by data, such as surf, imagesc and contourf, scale their values across the color limits and look the colors up in this table. The default is parula with 256 rows. Many maps take the number of colors as an argument, as in colormap(hot(8)).

Input arguments

map
m-by-3 matrix of RGB values between 0 and 1.
name
Name of a colormap function.

Output arguments

map
Current colormap, one RGB row per color.

Example

Reading and replacing the map

disp(size(colormap))
colormap(hot(8))
disp(size(colormap))
Output
   256     3
     8     3

See also

colorbar clim parula gray hot