axis(side, at=<<see below>>, labels=T, ticks=T, distn=NULL, line=0, pos=<<see below>>, outer=F, ...)
1
for bottom,
2
for left,
3
for top,
and
4
for right).
side
is
1
or
3
,
at
represents x-coordinates.
If
side
is
2
or
4
,
at
represents y-coordinates.
If
at
is omitted,
the current axis (as specified by the
xaxp
or
yaxp
parameters,
see
par
) will be plotted.
labels
is logical,
it specifies whether or not to plot tick labels.
Otherwise,
labels
must be the same length
as
at
,
and
label[i]
is plotted at
coordinate
at[i]
.
TRUE
, tick marks and the axis line
will be plotted.
distn="normal"
,
in which case values of
at
are assumed
to be probability levels,
and the labels are actually plotted at
qnorm(at)
.
This also implies a reasonable default set of values for the
at
argument.
By default the values in
at
are used as the labels.
mgp
).
side
.
If
pos
is omitted,
argument
line
controls positioning of the axis.
TRUE
,
the axis will be drawn in the outer margin rather than the standard plot margin.
title
such as
xlab
and
ylab
are not allowed.
For string rotation use the
las
graphical parameter:
0 = parallel to the axis (the default),
1 = horizontal,
2 = perpendicular to the axis.
The line type and line width used to draw the axes can be set with the
lty
and
lwd
parameters respectively (see Details below for more information).
If
at
is not given,
then
axis
uses the following procedure
to place the tick mark labels.
axis
rotates the tick mark labels
to be parallel to the axes
if the graphical parameter
las
is 0,
horizontal if
las
is 1,
and perpendicular to the axes if
las
is 2.
(This overrides the current value of the graphical parameter
srt
.)
The tick mark labels are centered at the tick mark if they are parallel
to the axis and right or left justified
if they are perpendicular to the axis and to the left or right of it,
respectively.
(This overrides the current value of the graphical parameter
adj
.)
If
at
is used to specify
where to place the tick mark labels,
then
axis
uses
srt
to specify how to rotate the labels
(ignoring the
las
parameter
and
side
argument)
and it uses the
adj
parameter
to specify the string adjustment
(ignoring the
side
argument).
The values of the
lty
and
lwd
parameters in
par
are ignored. The line type and line width used to draw the axes are always
lty=1
and
lwd=1
respectively, unless explicitly set with the
axis
function.
You can specify the size, type, and color of the text for the main title, subtitle, axis labels, and tick mark labels by using
arguments:
cex.main
,
font.main
, and
col.main
for the main title,
cex.sub
,
font.sub
, and
col.sub
for the subtitle,
cex.lab
,
font.lab
, and
col.lab
for the axis labels, and
col.axis
,
font.axis
, and
col.axis
for the tick mark labels, respectively.
plot(1:10, runif(10)) axis(3) # add axis on top axis(4, label=F) # tick marks only on right qqnorm(rnorm(50)) axis(3, distn="normal") # add normal probability axis at top qqnorm(rnorm(50), xaxt="n") # normal prob plot, no x axis labels probs <- c(.01, .05, .1, .9, .95, .99) axis(1, distn="norm", at=probs, lab=paste(probs*100, "%")) # add user-defined probability axis plot(rnorm(30), rnorm(30), axes=F) # scatter plot with no box or axes axis(1, pos=0); axis(2, pos=0) # coordinate axes through origin fahrenheit <- c(25, 28, 37, 49, 59, 69, 73, 71, 63, 52, 42, 29) par(oma=c(2,1,0,4)) plot(fahrenheit, axes=F, pch=12, xlab="", ylab="Fahrenheit", sub="Monthly Mean Temperatures for Hartford, Conn.") axis(2) axis(1, at=1:12, labels=month.abb) celsius <- pretty((range(fahrenheit)-32)*5/9) axis(side=4, at=celsius*9/5+32, lab=celsius, srt=90) # celsius at right mtext(side=4, line=4, "Celsius") box()