3-D Visualization |

**Indexed Color Surfaces -- Direct and Scaled Colormapping**

MATLAB can use two different methods to map indexed color data to the colormap -- direct and scaled.

**Direct Mapping**

Direct mapping uses the color data directly as indices into the colormap. For example, a value of 1 points to the first color in the colormap, a value of 2 points to the second color, and so on. If the color data is noninteger, MATLAB rounds it toward zero. Values greater than the number of colors in the colormap are set equal to the last color in the colormap (i.e., the number `length`

`(colormap)`

). Values less than 1 are set to 1.

**Scaled Mapping**

Scaled mapping uses a two-element vector `[cmin cmax]`

(specified with the `caxis`

command) to control the mapping of color data to the figure colormap. `cmin`

specifies the data value to map to the first color in the colormap and `cmax`

specifies the data value to map to the last color in the colormap. Data values in between are linearly transformed from the second to the next-to-last color, using the expression

`cm_length`

is the length of the colormap.

By default, MATLAB sets `cmin`

and `cmax`

to span the range of the color data of all graphics objects within the axes. However, you can set these limits to any range of values. This enables you to display multiple axes within a single figure window and use different portions of the figure's colormap for each one. See Calculating Color Limits" in Axes Properties of the Using MATLAB Graphics documentation for an example that uses color limits.

By default, MATLAB uses scaled mapping. To use direct mapping, you must turn off scaling when you create the plot. For example,

See `surface`

for more information on specifying color data.

**Specifying Indexed Colors**

When creating a surface plot with a single matrix argument, `surf(Z)`

for example, the argument `Z`

specifies both the height and the color of the surface. MATLAB transforms `Z`

to obtain indices into the current colormap.

With two matrix arguments, the statement

independently specifies the color using the second argument.

Colormaps | Example -- Mapping Surface Curvature to Color |

© 1994-2005 The MathWorks, Inc.