MATLAB Functions Help Desk

caxis

Purpose

Color axis scaling

Syntax

Description

caxis controls the mapping of data values to the colormap. It affects any Surfaces, Patches, and Images with indexed CData and CDataMapping set to scaled . It does not affect Surfaces, Patches, or Images with true color CData or with CDataMapping set to direct.

caxis([cmin cmax]) sets the color limits to specified minimum and maximum values. Data values less than cmin or greater than cmax map to cmin and cmax, respectively. Values between cmin and cmax linearly map to the current colormap.

caxis auto lets MATLAB compute the color limits automatically using the minimum and maximum data values. This is MATLAB's default behavior. Color values set to Inf have the maximum color and values set to -Inf have the minimum color. Faces or edges with color values set to NaN are not drawn.

caxis manual and caxis(caxis) freeze the color axis scaling at the current limits. This enables subsequent plots to use the same limits when hold is on.

v = caxis returns a two-element row vector containing the [cmin cmax] currently in use.

Examples

Create (X,Y,Z) data for a sphere of radius 1 and view the data as a Surface:

Values of C have the range [-1 1]. Values of C near -1 are assigned the lowest values in the colormap; values of C near +1 are assigned the highest values in the colormap.

Map the top half of the sphere to the highest value in the color table:

To use only the bottom half of the color table, enter

which maps the lowest CData values to the bottom of the colormap, and the hightest values to the middle of the colormap (by specifying a cmax whose value is equal to cmin plus twice the range of the CData).

The command

resets axis scaling back to auto-ranging and you see all the colors in the Surface. In this case, entering

returns

Algorithm

caxis changes the CLim and CLimMode properties of Axes graphics objects.

Surface, Patch and Image graphics objects with indexed CData and CDataMapping set to scaled map CData values to colors in the Figure colormap each time they render. CData values equal to or less than cmin map to the first color value in the colormap, and CData values equal to or greater than cmax map to the last color value in the colormap. MATLAB performs the following linear transformation on the intermediate values (referred to as C below) to map them to an entry in the colormap (whose length is m, and whose row index is referred to as index below):

See Also

axes, axis, colormap, get, mesh, pcolor, set, surf

The CLim and CLimMode properties of Axes graphics objects.

The ColorMap property of Figure graphics objects.

The Axes chapter in the Graphics User's Guide.



[ Previous | Help Desk | Next ]