
3 Graphics
surf(x,y,z,'FaceColor','interp',. ..
'FaceLighting','gouraud')
plots the data in the variables x, y,andz using a surfaceplot object with
interpolated face color and employing the Gouraud face light technique. You
can set any of the object’s properties this way.
Setting Properties of Existing Objects
To modify the property values of existing objects, y ou can use the set
command or the Property Editor. This s ection describes how to use the set
command. See “Us ing the Property Editor” on page 3-18 for more information.
Most plotting functions return the handles of the objects that they create
so you can modify the objects usin g the
set command. For example, the se
statements plot a 5-by-5 matrix (creating five lineseries, one per column), and
then set the
Marker property to a square and the Mar kerF aceColor property
to green:
h = plot(magic(5));
set(h,'Marker','s','MarkerFaceColo r','g')
In this case, h is a vector containing five handles, one for each of the
five lineseries in the graph. The
set statement sets the Marker and
MarkerFaceColor properties of all lineseries to the same values.
Setting Multiple Property Values
If you want to set the p ropertie s of each line series to a differe nt v alue, you
can use cell arrays to store all the data and pass it to the
set command. For
example, create a plot and save the linese ries handles:
h = plot(magic(5));
Suppose you want to add different markers to each lineseries and color the
marker’s face color the same color as the lineseries. You need to define two
cell arrays—one containing the property names and the other containing
the desired values of the properties.
The
prop_name cell array contains two elements:
prop_name(1) = {'Marker'};
3-78
Commentaires sur ces manuels