Graphics Programs Reference
In-Depth Information
>> set(gca, 'FontName', 'Symbol')
>> set(gca, 'XTickLabel', '-2p|-p|0|p|2p')
since in the Symbol font,
π
occupies the slot held by
p
in text fonts.
Full-Fledged Customization
What about changes to other aspects of a plot? The useful commands
get
and
set
canbeusedtoobtainacompletelistofthepropertiesofagraphicswindow,
and then to modify them. These properties are arranged in a hierarchical
structure, identified by markers (which are simply numbers) called
handles
.
If you type
get(gcf)
, you will “get” a (rather long) list of properties of the
current figure (whose number is returned by the function
gcf
). Some of these
might read
Color = [0.8 0.8 0.8]
CurrentAxes = [72.0009]
PaperSize = [8.5 11]
Children = [72.0009]
Here
PaperSize
is self-explanatory;
Color
gives the background color of the
plot in RGB (red-green-blue) coordinates, where [0 0 0] is black and [1 1 1]
is white. ([0.8 0.8 0.8] is light gray.) Note that
CurrentAxes
and
Children
in this example have the same value, the one-element vector containing the
funny-looking number 72.0009. This number would also be returned by the
command
gca
(“get current axes”); it is the handle to the axis properties of
the plot. The fact that this also shows up under
Children
indicates that the
axispropertiesare“children”ofthefigure,thisis,theylieoneleveldowninthe
hierarchical structure. Typing
get(gca)
or
get(72.0009)
would then give
you a list of axis properties, including further
Children
suchas
Line
objects,
within which you would find the
XData
and
YData
encoding the actual plot.
Once you have located the properties you're interested in, they can be
changed with
set
. For example,
>> set(gcf, 'Color', [1 0 0])
changes the background color of the border of the figure window to red, and
>> set(gca, 'Color', [1 1 0])
changes the background color of the plot itself (a child of the figure window)
to yellow (which in the RGB scheme is half red, half green).
Search WWH ::
Custom Search