Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

caxis

Set colormap limits

Syntax

caxis(limits)
caxis('auto')
caxis('manual')
caxis(target,___)
cl = caxis

Description

example

caxis(limits) sets the colormap limits for the current axes. limits is a two-element vector of the form [cmin cmax]. All values in the colormap indexing array that are less than or equal to cmin map to the first row in the colormap. All values that are greater than or equal to cmax map to the last row in the colormap. All values between cmin and cmax map linearly to the intermediate rows of the colormap.

Note

The caxis function only affects graphics objects that have the CDataMapping property set to 'scaled'. It does not affect graphics objects that use truecolor or have the CDataMapping set to 'direct'.

example

caxis('auto') enables automatic limit updates when values in the colormap indexing array change. This is the default behavior. The caxis auto command is an alternative form of this syntax.

example

caxis('manual') disables automatic limit updates. The caxis manual command is an alternative form of this syntax.

example

caxis(target,___) sets the colormap limits for a specific axes or chart. Specify target as the first input argument in any of the previous syntaxes.

example

cl = caxis returns the current colormap limits for the current axes or chart.

Examples

collapse all

Plot a paraboloid with a colorbar.

[X,Y] = meshgrid(-5:.5:5);
Z = X.^2 + Y.^2;
surf(Z);
colorbar

Get the current color limits.

lim = caxis
lim = 

     0    50

Raise the lower limit to 20. Notice that all values of Z that are less than or equal to 20 map to the first color.

caxis([20 50])

Create two paraboloid surfaces that are vertically offset.

[X,Y] = meshgrid(-5:.5:5);
Z1 = X.^2 + Y.^2;
Z2 = Z1 + 50;

Plot the first paraboloid. Add a colorbar, and hold the axes for the second paraboloid.

surf(X,Y,Z1);
colorbar
hold on

Hold the current color limits using the 'manual' option. Then plot the second paraboloid.

caxis('manual');
surf(X,Y,Z2);

Plot a paraboloid in two subplots.

[X,Y] = meshgrid(-5:1:5);
Z = X.^2 + Y.^2;
ax1 = subplot(1,2,1);
surf(ax1,Z);
ax2 = subplot(1,2,2);
surf(ax2,Z);

Raise the lower color limit of the right axes to 20.

caxis(ax2,[20 50])

Input Arguments

collapse all

New limits, specified as a vector of the form [cmin cmax]. The value of cmin must be less than cmax.

Data Types: single | double

Target axes or chart, specified as an Axes object or a graphics object that has a Colormap property (such as a HeatMapChart object).

Output Arguments

collapse all

Current limits of the current axes or chart, returned as a vector of the form [cmin cmax].

More About

collapse all

Colormap Indexing Array

An array that maps data elements in a chart to specific rows in the colormap. MATLAB® stores the indexing array as a property on the graphics object.

For example, the CData property of a Surface object is an indexing array that maps grid points on the surface to specific rows in the colormap.

Introduced before R2006a

Was this topic helpful?