\Header{mtext}{Write Text into the Margins of a Plot}
\keyword{aplot}{mtext}
\begin{Description}\relax
Text is written in one of the four margins of the current figure region
or one of the outer margins of the device region.
\end{Description}
\begin{Usage}
\begin{verbatim}
mtext(text, side = 3, line = 0, outer = FALSE, at = NA,
      adj = NA, cex = NA, col = NA, font = NA, vfont = NULL, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{text}] one or more character strings or expressions.
\item[\code{side}] on which side of the plot (1=bottom, 2=left, 3=top, 4=right).
\item[\code{line}] on which MARgin line, starting at 0 counting outwards.
\item[\code{outer}] use outer margins if available.
\item[\code{at}] give location in user-coordinates.  If \code{length(at)==0}
(the default), the location will be determined by \code{adj}.

\item[\code{adj}] adjustment for each string. For strings parallel
to the axes, \code{adj=0} means left or bottom alignment, and
\code{adj=1} means right or top alignment.
If \code{adj} is not a finite value (the default), the value of
\code{par("las")} determines the adjustment.  For strings plotted
parallel to the axis the default is to centre the string.
\item[\code{...}] Further graphical parameters (see \code{\Link{text}} and
\code{\Link{par}}) ; currently supported are:
\item[\code{cex}] character expansion factor (default = 1).
\item[\code{col}] color to use.
\item[\code{font}] font for text.
\item[\code{vfont}] vector font for text.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The \dQuote{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{} is differing here from other implementations of S.

The arguments \code{side}, \code{line}, \code{at}, \code{at},
\code{adj}, the further graphical parameters and even \code{outer} can
be vectors, and recycling will take place to plot as many strings as
the longest of the vector arguments.  Note that a vector \code{adj}
has a different meaning from \code{\Link{text}}.

\code{adj = 0.5} will centre the string, but for \code{outer=TRUE} on
the device region rather than the plot region.

Parameter \code{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 \code{srt} if
\code{at} is supplied and \code{las} if it is not.)

Note that if the text is to be plotted perpendicular to the axis,
\code{adj} determines the justification of the string \emph{and} the
position along the axis unless \code{at} is specified.
\end{Details}
\begin{Section}{Side Effects}
The given text is written onto the current plot.
\end{Section}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole.
\end{References}
\begin{SeeAlso}\relax
\code{\Link{title}}, \code{\Link{text}}, \code{\Link{plot}},
\code{\Link{par}};
\code{\Link{plotmath}} for details on mathematical annotation.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
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)
\end{ExampleCode}
\end{Examples}

