Set colormap limits
caxis( 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
cmax map linearly to the intermediate rows of the colormap.
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
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
caxis('manual') disables automatic limit updates. The
caxis manual command is an alternative form of this
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 = 1×2 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.
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.
Starting in R2019b, you can display a tiling of plots using the
nexttile functions. Call the
tiledlayout function to create a 1-by-2 tiled chart layout. Call the
nexttile function to create the axes objects
ax2. Plot a paraboloid into each axes.
[X,Y] = meshgrid(-5:1:5); Z = X.^2 + Y.^2; tiledlayout(1,2) % Left plot ax1 = nexttile; surf(ax1,Z); % Right plot ax2 = nexttile; surf(ax2,Z);
Raise the lower color limit of the right axes to
limits— New limits
New limits, specified as a vector of the form
cmax]. The value of
cmin must be less than
target— Target object
GeographicAxesobject | standalone visualization
Target object, specified as an
PolarAxes object, a
object, or a standalone visualization that has a
cl— Current limits
Current limits of the current axes or chart, returned as a vector of the
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.