Graphics Programs Reference
In-Depth Information
Here we would probably want the tick marks on the
x
axis located at mul-
tiples of
π
. This can be done with the
set
command applied to the properties
of the axes (and/or by selecting
Edit
:
Axes Properties...
in MATLAB 6,
or
Tools
:
Axes Properties...
in MATLAB 5.3). The command
set
is used
to change various properties of graphics. To apply it to “Axes”, it has to be
combined withthe command
gca
, which stands for “get current axes”. The
code
>> set(gca, 'XTick', (-2:2)*pi, 'XTickLabel',...
'-2pi|-pi|0|pi|2pi')
in combination with the code above gets the current axes, sets the ticks on
the
x
axis to go from
−
2
π
to 2
π
in multiples of
π
, and then labels these ticks
the way one would want (rather than in decimal notation, which is ugly here).
TheresultisshowninFigure5-10.Incidentally,youmightwonderhowtolabel
the ticks as
−
2
π
,
−
π
, etc., instead of
-2pi
,
-pi
, and so on. This is trickier but
you can do it by typing
1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
-2pi
-pi
0
pi
2pi
Figure5-10
Search WWH ::
Custom Search