mtext {graphics} | R Documentation |
Text is written in one of the four margins of the current figure region or one of the outer margins of the device region.
mtext(text, side = 3, line = 0, outer = FALSE, at = NA,
adj = NA, padj = NA, cex = NA, col = NA, font = NA, ...)
text |
a character or expression vector specifying
the text to be written. Other objects are coerced by
|
side |
on which side of the plot (1=bottom, 2=left, 3=top, 4=right). |
line |
on which MARgin line, starting at 0 counting outwards. |
outer |
use outer margins if available. |
at |
give location in user coordinates. If |
adj |
adjustment for each string in reading direction. For
strings parallel to the axes, If |
padj |
adjustment for each string perpendicular to the reading
direction (which is controlled by If |
cex |
character expansion factor. |
col |
color to use. Can be a vector. |
font |
font for text. Can be a vector. |
... |
Further graphical parameters (see |
The user coordinates in the outer margins always range from zero to one, and are not affected by the user coordinates in the figure region(s) — R differs here from other implementations of S.
All of the named arguments can be vectors, and recycling will take place to plot as many strings as the longest of the vector arguments.
Note that a vector adj
has a different meaning from
text
. adj = 0.5
will centre the string, but for
outer=TRUE
on the device region rather than the plot region.
Parameter las
will determine the orientation of the string(s).
For strings plotted perpendicular to the axis the default justification
is to place the end of the string nearest the axis on the specified
line. (Note that this differs from S, which uses srt
if
at
is supplied and las
if it is not. Parameter
srt
is ignored in R.)
Note that if the text is to be plotted perpendicular to the axis,
adj
determines the justification of the string and the
position along the axis unless at
is specified.
The given text is written onto the current plot.
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
title
, text
, plot
,
par
;
plotmath
for details on mathematical annotation.
plot(1:10, (-4:5)^2, main="Parabola Points", xlab="xlab")
mtext("10 of them")
for(s in 1:4)
mtext(paste("mtext(..., line= -1, {side, col, font} = ",s,
", cex = ", (1+s)/2, ")"), line = -1,
side=s, col=s, font=s, cex= (1+s)/2)
mtext("mtext(..., line= -2)", line = -2)
mtext("mtext(..., line= -2, adj = 0)", line = -2, adj =0)
##--- log axis :
plot(1:10, exp(1:10), log='y', main="log='y'", xlab="xlab")
for(s in 1:4) mtext(paste("mtext(...,side=",s,")"), side=s)