www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/ChangeColorAxisScalingExample.m

    %% Change Color Axis Scaling
% Define |X|, |Y|, and |Z| as data for a sphere and view the data as a
% surface. Define the colors for the surface, |C|. 

% Copyright 2015 The MathWorks, Inc.


[X,Y,Z] = sphere;
C = Z;
surf(X,Y,Z,C)

%%
% Values of |C| are in 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 surface to the highest value in the color table
% by setting the maximum color limit to 0. 
caxis([-1,0])

%%
% Reset the axis scaling back to its default range.

caxis auto

%%
% Return the values of the current color limits. 
v = caxis