colormap

Gets or sets the colormap of a figure or axes.

Syntax

cmap = colormap()

cmap = colormap(handle)

colormap(cmap)

colormap(cmapname)

colormap(handle, cmap)

Inputs

handle
The handle of the figure or axes.
Type: double | integer
Dimension: scalar
cmap
n x 3 matrix to set the colormap.
Type: double | integer
Dimension: matrix
cmapname
Colormap name. Available options are:
'autumn'
'bone'
'cividis'
'cool'
'copper'
'cubehelix'
'flag'
'gray'
'hot'
'hsv'
'inferno'
'jet'
'lines'
'magma'
'ocean'
'pink'
'plasma'
'prism'
'rainbow'
'spring'
'summer'
'twilight'
'viridis'
'white'
'winter'
Type: char
Dimension: string

Outputs

cmap
The current colormap.

Example

Simple colormap example.
x=[0:0.1:2*pi];
y=x;
z=sin(x')*cos(y);
contour(z)
cmap = [1 0 0;0 1 0; 0 0 1; 0 0 0];
colormap(cmap)
Simple colormap example using 'viridis colormap'.
x=[0:0.1:2*pi];
y=x;
z=sin(x')*cos(y);
contour(z)
colormap('viridis')

Comments

The maximum number of colors in the colormap is 32.