Graphics Reference
In-Depth Information
3.11 Other Graphics Handling Options
Graphic characteristics treated so far belong to the high level MATLAB GUI. However, there are low level
(
Handle Graphics
) commands that allow creation and manipulation of figures, axes, lines, surfaces, images, text,
menus and other graphics objects. Some of the commands to create graphical objects are:
Figure(h)
or
h = figure
create the figure as an object of name
h
, and is located as a current
figure. The
gcf(h)
(get current handle)
command generally means return the handle to the
figure. The command
close(h)
closes figure
h
.
The command
whitebg(h)
changes the color
of the background of the figure
h
. The command
clf
closes the current figure. The command
graymon
is used for legibility of grayscale. The command
refresh
redraws the figure.
axes(e)
or
e = axes
creates the axes as an object of name e, in the current figure. Use the
command
gca(e)
to refer to any property of the e axes.
The
cla
command is used to delete
all the objects referring to the current axes.
l = line(x,y)
or
l = line(x, y, z)
creates an object of name
l
, the line joining the points
(X, Y)
in the flat, or
(X, Y, Z)
space.
p = patch(X, Y, C)
or
patch(X,Y,Z,C)
creates an opaque polygonal area that is defined by
the set of points
(X, Y)
in the flat, or
(X, Y, Z)
space, and whose color is given by
C
, as an
object of name
p.
s = surface(X,Y,Z,C)
creates the parametric surface defined by
X
,
Y
and
Z
, and whose color
is given by
C,
as an object of named
s.
i = image(C)
creates the image defined by the colors in the array
C
as an object of name
i.
t = text(x, y, 'string')
or
t = text(x, y, z, 'string')
creates the text defined by the parameter in
single quotes, located at the point in the
(x, y)
plane, or at the point in the
(x, y, z)
space.
Each object has a level of hierarchy. The parents of an object are superior in the hierarchy, and children are the
objects of a lower hierarchy. The object is created with
figure
, then, the one created by
axes
and, finally, and at the
same level, are the ones created by
image
,
patch
,
surface
,
text
and
line
. This means that if, for example, you want to
create a surface, first has to create the figure that is going to be graphed, then the axes, and, finally, the surface itself.
So far we have seen commands that allow you to create objects, but, in addition, all these objects can have
properties, as style of line, color, etc. The list of possible properties for each object is very long, and so full knowledge
of the list requires consultation of
MATLAB Reference
manual,
http://www.mathworks.com/help/matlab/
.
As a
general rule, the name of a property of an object is a compound word whose components begin with capital letter. For
example, the line style property has the name
LineStyle
. The names of the properties that are mapped by default to an
object start with
Default
, as, for example,
DefaultFigureColor
, which assigns the color by default to a figure. Below, are
some of the most typical properties for the different objects.