caxis
Color axis scaling
Syntax
caxis([cmin cmax])
caxis auto
caxis manual
caxis(caxis)
v = caxis
caxis(target,...)
Description
caxis
controls the mapping of data values to the colormap.
caxis([cmin cmax])
sets the color limits for the current axes or chart returned by thegca
command. Data values less thancmin
or greater thancmax
map tocmin
andcmax
, respectively. Values betweencmin
andcmax
linearly map to the current colormap.
caxis auto
computes the color limits automatically using the minimum and maximum data values. This is the default behavior. Color values set toInf
map to the maximum color, and values set to -Inf
map to the minimum color. Faces or edges with color values set toNaN
are not drawn.
caxis manual
andcaxis(caxis)
freeze the color axis scaling at the current limits. This enables subsequent plots to use the same limits whenhold
ison
.
v = caxis
returns a two-element row vector containing the[cmin
cmax]
currently in use.
caxis(target,...)
uses the axes or chart specified bytarget
instead of the current axes or chart.
Input Arguments
Examples
Tips
How Color Axis Scaling Works
Surface, patch, and image graphics objects having indexedCData
andCDataMapping
set toscaled
mapCData
values to colors in the figure colormap each time they render.CData
values equal to or less thancmin
map to the first color value in the colormap, andCData
values equal to or greater thancmax
map to the last color value in the colormap. The following linear transformation is performed on the intermediate values (referred to asC
below) to map them to an entry in the colormap (whose length ism
, and whose row index is referred to asindex
below).
index = fix((C-cmin)/(cmax-cmin)*m)+1; %Clamp values outside the range [1 m] index(index<1) = 1; index(index>m) = m;