| Line 1... |
Line 1... |
| 1 |
% File src/library/graphics/man/text.Rd
|
1 |
% File src/library/graphics/man/text.Rd
|
| 2 |
% Part of the R package, https://www.R-project.org
|
2 |
% Part of the R package, https://www.R-project.org
|
| 3 |
% Copyright 1995-2016 R Core Team
|
3 |
% Copyright 1995-2018 R Core Team
|
| 4 |
% Distributed under GPL 2 or later
|
4 |
% Distributed under GPL 2 or later
|
| 5 |
|
5 |
|
| 6 |
\name{text}
|
6 |
\name{text}
|
| 7 |
\title{Add Text to a Plot}
|
7 |
\title{Add Text to a Plot}
|
| 8 |
\encoding{UTF-8}
|
8 |
\encoding{UTF-8}
|
| Line 24... |
Line 24... |
| 24 |
language objects (names and calls) to expressions, and vectors and
|
24 |
language objects (names and calls) to expressions, and vectors and
|
| 25 |
other classed objects to character vectors by \code{\link{as.character}}.
|
25 |
other classed objects to character vectors by \code{\link{as.character}}.
|
| 26 |
If \code{labels} is longer than \code{x} and
|
26 |
If \code{labels} is longer than \code{x} and
|
| 27 |
\code{y}, the coordinates are recycled to the length of \code{labels}.}
|
27 |
\code{y}, the coordinates are recycled to the length of \code{labels}.}
|
| 28 |
\item{adj}{one or two values in \eqn{[0, 1]} which specify the x
|
28 |
\item{adj}{one or two values in \eqn{[0, 1]} which specify the x
|
| 29 |
(and optionally y) adjustment of the labels. On most devices values
|
29 |
(and optionally y) adjustment (\sQuote{justification}) of the
|
| - |
|
30 |
labels, with 0 for left/bottom, 1 for right/top, and 0.5 for
|
| - |
|
31 |
centered. On most devices values outside \eqn{[0, 1]} will also
|
| 30 |
outside that interval will also work.}
|
32 |
work. See below.}
|
| 31 |
\item{pos}{a position specifier for the text. If specified this
|
33 |
\item{pos}{a position specifier for the text. If specified this
|
| 32 |
overrides any \code{adj} value given. Values of \code{1},
|
34 |
overrides any \code{adj} value given. Values of \code{1},
|
| 33 |
\code{2}, \code{3} and \code{4}, respectively indicate
|
35 |
\code{2}, \code{3} and \code{4}, respectively indicate
|
| 34 |
positions below, to the left of, above and to the right of
|
36 |
positions below, to the left of, above and to the right of
|
| 35 |
the specified coordinates.}
|
37 |
the specified \code{(x,y)} coordinates.}
|
| 36 |
\item{offset}{when \code{pos} is specified, this value gives the
|
38 |
\item{offset}{when \code{pos} is specified, this value controls the
|
| 37 |
offset of the label from the specified coordinate in fractions
|
39 |
distance (\sQuote{offset}) of the text label from the specified
|
| 38 |
of a character width.}
|
40 |
coordinate in fractions of a character width.}
|
| 39 |
\item{vfont}{\code{NULL} for the current font family, or a character
|
41 |
\item{vfont}{\code{NULL} for the current font family, or a character
|
| 40 |
vector of length 2 for Hershey vector fonts. The first element of
|
42 |
vector of length 2 for Hershey vector fonts. The first element of
|
| 41 |
the vector selects a typeface and the second element selects a
|
43 |
the vector selects a typeface and the second element selects a
|
| 42 |
style. Ignored if \code{labels} is an expression.}
|
44 |
style. Ignored if \code{labels} is an expression.}
|
| 43 |
\item{cex}{numeric \bold{c}haracter \bold{ex}pansion factor; multiplied
|
45 |
\item{cex}{numeric \bold{c}haracter \bold{ex}pansion factor; multiplied
|
| Line 60... |
Line 62... |
| 60 |
\code{\link{expression}} (or be coercible to such a type).
|
62 |
\code{\link{expression}} (or be coercible to such a type).
|
| 61 |
In the latter case, quite a bit of
|
63 |
In the latter case, quite a bit of
|
| 62 |
mathematical notation is available such as sub- and superscripts,
|
64 |
mathematical notation is available such as sub- and superscripts,
|
| 63 |
greek letters, fractions, etc.
|
65 |
greek letters, fractions, etc.
|
| 64 |
|
66 |
|
| 65 |
\code{adj} allows \emph{adj}ustment of the text with respect to
|
67 |
\code{adj} allows \emph{adj}ustment of the text position with respect to
|
| 66 |
\code{(x, y)}.
|
68 |
\code{(x, y)}.
|
| 67 |
Values of 0, 0.5, and 1 specify left/bottom, middle and
|
69 |
Values of 0, 0.5, and 1 specify that \code{(x, y)} should align with
|
| - |
|
70 |
the left/bottom, middle and
|
| 68 |
right/top alignment, respectively. The default is for centered text, i.e.,
|
71 |
right/top of the text, respectively. The default is for centered text, i.e.,
|
| 69 |
\code{adj = c(0.5, NA)}. Accurate vertical centering needs
|
72 |
\code{adj = c(0.5, NA)}. Accurate vertical centering needs
|
| 70 |
character metric information on individual characters which is
|
73 |
character metric information on individual characters which is
|
| 71 |
only available on some devices. Vertical alignment is done slightly
|
74 |
only available on some devices. Vertical alignment is done slightly
|
| 72 |
differently for character strings and for expressions:
|
75 |
differently for character strings and for expressions:
|
| 73 |
\code{adj = c(0,0)} means to left-justify and to align on the baseline
|
76 |
\code{adj = c(0,0)} means to left-justify and to align on the baseline
|
| Line 79... |
Line 82... |
| 79 |
The \code{pos} and \code{offset} arguments can be used in conjunction
|
82 |
The \code{pos} and \code{offset} arguments can be used in conjunction
|
| 80 |
with values returned by \code{identify} to recreate an interactively
|
83 |
with values returned by \code{identify} to recreate an interactively
|
| 81 |
labelled plot.
|
84 |
labelled plot.
|
| 82 |
|
85 |
|
| 83 |
Text can be rotated by using \link{graphical parameters} \code{srt}
|
86 |
Text can be rotated by using \link{graphical parameters} \code{srt}
|
| 84 |
(see \code{\link{par}}); this rotates about the centre set by
|
87 |
(see \code{\link{par}}). When \code{adj} is specified, a non-zero
|
| - |
|
88 |
\code{srt} rotates the label about \code{(x, y)}. If \code{pos} is
|
| - |
|
89 |
specified, \code{srt} rotates the text about the point on its bounding
|
| - |
|
90 |
box which is closest to \code{(x, y)}: top center for \code{pos = 1},
|
| - |
|
91 |
right center for \code{pos = 2}, bottom center for \code{pos = 3}, and
|
| - |
|
92 |
left center for \code{pos = 4}. The \code{pos} interface is not as
|
| - |
|
93 |
useful for rotated text because the result is no longer centered
|
| - |
|
94 |
vertically or horizontally with respect to \code{(x, y)}. At present
|
| - |
|
95 |
there is no interface in the \pkg{graphics} package for directly
|
| - |
|
96 |
rotating text about its center which is achievable however by fiddling
|
| 85 |
\code{adj}.
|
97 |
with \code{adj} and \code{srt} simultaneously.
|
| 86 |
|
98 |
|
| 87 |
Graphical parameters \code{col}, \code{cex} and \code{font} can be
|
99 |
Graphical parameters \code{col}, \code{cex} and \code{font} can be
|
| 88 |
vectors and will then be applied cyclically to the \code{labels} (and
|
100 |
vectors and will then be applied cyclically to the \code{labels} (and
|
| 89 |
extra values will be ignored). \code{NA} values of \code{font} are
|
101 |
extra values will be ignored). \code{NA} values of \code{font} are
|
| 90 |
replaced by \code{par("font")}, and similarly for \code{col}.
|
102 |
replaced by \code{par("font")}, and similarly for \code{col}.
|