| Line 24... |
Line 24... |
| 24 |
\details{
|
24 |
\details{
|
| 25 |
Unit objects allow the user to specify locations and dimensions
|
25 |
Unit objects allow the user to specify locations and dimensions
|
| 26 |
in a large number of different coordinate systems. All drawing
|
26 |
in a large number of different coordinate systems. All drawing
|
| 27 |
occurs relative to a viewport and the \code{units} specifies
|
27 |
occurs relative to a viewport and the \code{units} specifies
|
| 28 |
what coordinate system to use within that viewport.
|
28 |
what coordinate system to use within that viewport.
|
| 29 |
|
29 |
|
| 30 |
Possible \code{units} (coordinate systems) are:
|
30 |
Possible \code{units} (coordinate systems) are:
|
| 31 |
\describe{
|
31 |
\describe{
|
| 32 |
\item{\code{"npc"}}{Normalised Parent Coordinates (the default).
|
32 |
\item{\code{"npc"}}{Normalised Parent Coordinates (the default).
|
| 33 |
The origin of the viewport is (0, 0) and the viewport has a width
|
33 |
The origin of the viewport is (0, 0) and the viewport has a width
|
| 34 |
and height of 1 unit. For example, (0.5, 0.5) is the centre of
|
34 |
and height of 1 unit. For example, (0.5, 0.5) is the centre of
|
| Line 51... |
Line 51... |
| 51 |
the viewport's \code{xscale} and \code{yscale}.}
|
51 |
the viewport's \code{xscale} and \code{yscale}.}
|
| 52 |
\item{\code{"snpc"}}{Square Normalised Parent Coordinates.
|
52 |
\item{\code{"snpc"}}{Square Normalised Parent Coordinates.
|
| 53 |
Same as Normalised Parent Coordinates, except gives the same answer for
|
53 |
Same as Normalised Parent Coordinates, except gives the same answer for
|
| 54 |
horizontal and vertical locations/dimensions. It uses the
|
54 |
horizontal and vertical locations/dimensions. It uses the
|
| 55 |
\emph{lesser} of npc-width and npc-height. This is useful for making
|
55 |
\emph{lesser} of npc-width and npc-height. This is useful for making
|
| 56 |
things which are a proportion of the viewport, but have to be square
|
56 |
things which are a proportion of the viewport, but have to be square
|
| 57 |
(or have a fixed aspect ratio).}
|
57 |
(or have a fixed aspect ratio).}
|
| 58 |
\item{\code{"strwidth"}}{Multiples of the width of the string
|
58 |
\item{\code{"strwidth"}}{Multiples of the width of the string
|
| 59 |
specified in the \code{data} argument. The font size is
|
59 |
specified in the \code{data} argument. The font size is
|
| 60 |
determined by the pointsize of the viewport.}
|
60 |
determined by the pointsize of the viewport.}
|
| 61 |
\item{\code{"strheight"}}{Multiples of the height of the string
|
61 |
\item{\code{"strheight"}}{Multiples of the height of the string
|
| Line 69... |
Line 69... |
| 69 |
|
69 |
|
| 70 |
A number of variations are also allowed for the most common units.
|
70 |
A number of variations are also allowed for the most common units.
|
| 71 |
For example, it is possible to use \code{"in"} or \code{"inch"}
|
71 |
For example, it is possible to use \code{"in"} or \code{"inch"}
|
| 72 |
instead of \code{"inches"} and \code{"centimetre"} or
|
72 |
instead of \code{"inches"} and \code{"centimetre"} or
|
| 73 |
\code{"centimeter"} instead of \code{"cm"}.
|
73 |
\code{"centimeter"} instead of \code{"cm"}.
|
| 74 |
|
74 |
|
| 75 |
A special \code{units} value of \code{"null"} is also allowed,
|
75 |
A special \code{units} value of \code{"null"} is also allowed,
|
| 76 |
but only makes sense when used in specifying widths of columns
|
76 |
but only makes sense when used in specifying widths of columns
|
| 77 |
or heights of rows in grid layouts (see \code{\link{grid.layout}}).
|
77 |
or heights of rows in grid layouts (see \code{\link{grid.layout}}).
|
| 78 |
|
78 |
|
| 79 |
The \code{data} argument must be a list when the \code{unit.length()}
|
79 |
The \code{data} argument must be a list when the \code{unit.length()}
|
| 80 |
is greater than 1. For example,
|
80 |
is greater than 1. For example,
|
| 81 |
\preformatted{ unit(rep(1, 3), c("npc", "strwidth", "inches"),
|
81 |
\preformatted{ unit(rep(1, 3), c("npc", "strwidth", "inches"),
|
| 82 |
data = list(NULL, "my string", NULL))
|
82 |
data = list(NULL, "my string", NULL))
|
| 83 |
}.
|
83 |
}.
|
| 84 |
|
84 |
|
| 85 |
It is possible to subset unit objects in the normal way
|
85 |
It is possible to subset unit objects in the normal way
|
| 86 |
(e.g., \code{unit(1:5, "npc")[2:4]}), but a special function
|
86 |
(e.g., \code{unit(1:5, "npc")[2:4]}), but a special function
|
| 87 |
\code{unit.c} is provided for combining unit objects.
|
87 |
\code{unit.c} is provided for combining unit objects.
|
| 88 |
|
88 |
|
| 89 |
Certain arithmetic and summary operations are defined for
|
89 |
Certain arithmetic and summary operations are defined for
|
| Line 104... |
Line 104... |
| 104 |
work exactly the same as
|
104 |
work exactly the same as
|
| 105 |
\code{"lines"}, \code{"char"}, \code{"strwidth"},
|
105 |
\code{"lines"}, \code{"char"}, \code{"strwidth"},
|
| 106 |
\code{"strheight"}.
|
106 |
\code{"strheight"}.
|
| 107 |
}
|
107 |
}
|
| 108 |
\value{
|
108 |
\value{
|
| 109 |
An object of class \code{"unit"}.
|
109 |
An object of class \code{"unit"}.
|
| 110 |
}
|
110 |
}
|
| 111 |
\author{Paul Murrell}
|
111 |
\author{Paul Murrell}
|
| 112 |
\seealso{
|
112 |
\seealso{
|
| 113 |
\code{\link{unit.c}}
|
113 |
\code{\link{unit.c}}
|
| 114 |
}
|
114 |
}
|