Graphics Programs Reference
In-Depth Information
4.7 Axes
So far we have allowed matlab to choose the axes for our plots. You
can change the axes in many ways:
axis([
xmin xmax ymin ymax
])
sets the axes' minimum and
maximum values
axis square
makes the axes the same length
axis equal
makes the axes the same scale
axis tight
sets the axes limits to the range of the data
allows matlab to choose axes limits
axis auto
removes the axes leaving only the plotted data
axis off
puts the axes back again
axis on
draws dotted grid lines
grid on
removes grid lines
grid off
toggles the grid
grid
box
∗
toggles the box
zeroaxes
∗
draws the
x
-axis at
y
= 0 and vice-versa
The functions marked with an asterisk
∗
are nonstandard features, imple-
mented in this topic's companion m-files.
1
4.8 Labels
You can put labels, titles, and text on a plot by using the commands:
xlabel('
text
')
ylabel('
text
')
zlabel('
text
')
title('
text
')
text(
x
,
y
,'
text
')
places text at position
x
,
y
gtext('
text
')
use mouse to place text
To put mathematics in labels you can use matlab's backslash nota-
tion (familiar to users of the T
E
X typesetting system):
t = 0:.1:2*pi;
y1 = cos(t);
y2 = sin(t);
plot(t,y1,t,y2)
xlabel('0 \leq \theta < 2\pi')
ylabel('sin \theta, cos \theta')
text(1,cos(1),' cosine')
text(3,sin(3),' sine')
box
1
matlab version 5.3 implements its own version of the
box
command.
