%% Changing Surface Properties
% This example shows how to get properties of a surface plot in MATLAB® and change the property values to customize your plot.
%
%% Surface Objects
% There are several ways to create a surface object in MATLAB. One way is to use surf.

[X,Y,Z] = peaks(50);

figure
surf(X,Y,Z)

%
% Like all graphics objects, surfaces have properties that you can view and modify. These properties have default values. The display of the surface object, s, shows the most commonly used surface properties, such as EdgeColor, LineStyle, FaceColor, and FaceLighting.

s = surf(X,Y,Z)

%
%% Get Individual Surface Properties
% To access individual properties, use dot notation syntax object.PropertyName. For example, return the FaceColor property of the surface.

s.FaceColor

%
%% Change Commonly Used Surface Properties
% Several functions are available to change surface properties. For example, use the shading function to control the shading of your surface.

shading interp    % interpolate the colormap across the surface face

%
% Use the lighting function to adjust the lighting characteristics of your surface. In order for lighting to have any affect, you must light your surface by creating a light object.

light               % create a light
lighting gouraud    % preferred method for lighting curved surfaces

%
% To change the reflectance property of your surface, use the material function.

material dull    % set material to be dull, no specular highlights

%
% To set the transparency for all objects in the current axes, use the alpha function. This function sets the transparency to any value between 1 and 0, where 1 means fully opaque and 0 means completely transparent.

alpha(0.8)    % set transparency to 0.8

%
%% Change Other Surface Properties
% To customize the look of your surface, change property values using dot notation.
% CData defines the colors for the vertices of the surface. The FaceColor property indicates how the colors of the surface faces are determined from the vertex colors.

s.CData = hypot(X,Y);      % set color data
s.FaceColor = 'interp';    % interpolate to get face colors

%
% AlphaData defines the transparency for each vertex of the surface. The FaceAlpha property indicates how the transparency of the surface faces are determined from vertex transparency.

s.AlphaData = gradient(Z);    % set vertex transparencies
s.FaceAlpha = 'interp';       % interpolate to get face transparencies

%
%% Get All Surface Properties
% Graphics objects in MATLAB have many properties. To see all the properties of a surface, use the get command.

get(s)

%
% Copyright 1984-2014 The MathWorks, Inc.