grid.layout.html
4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>R: Create a Grid Layout</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../R.css">
</head><body>
<table width="100%" summary="page for grid.layout {grid}"><tr><td>grid.layout {grid}</td><td align="right">R Documentation</td></tr></table>
<h2>Create a Grid Layout</h2>
<h3>Description</h3>
<p>
This function returns a Grid layout, which describes a subdivision
of a rectangular region.
</p>
<h3>Usage</h3>
<pre>
grid.layout(nrow = 1, ncol = 1,
widths = unit(rep(1, ncol), "null"),
heights = unit(rep(1, nrow), "null"),
default.units = "null", respect = FALSE,
just="centre")
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>nrow</code></td>
<td>
An integer describing the number of rows in the layout.</td></tr>
<tr valign="top"><td><code>ncol</code></td>
<td>
An integer describing the number of columns in the layout.</td></tr>
<tr valign="top"><td><code>widths</code></td>
<td>
A numeric vector or unit object
describing the widths of the columns
in the layout.</td></tr>
<tr valign="top"><td><code>heights</code></td>
<td>
A numeric vector or unit object
describing the heights of the rows
in the layout.</td></tr>
<tr valign="top"><td><code>default.units</code></td>
<td>
A string indicating the default units to use
if <code>widths</code> or <code>heights</code> are only given as numeric vectors.</td></tr>
<tr valign="top"><td><code>respect</code></td>
<td>
A logical value or a numeric matrix.
If a logical, this indicates whether
row heights and column widths should respect each other.
If a matrix, non-zero values indicate that the corresponding
row and column should be respected (see examples below).
</td></tr>
<tr valign="top"><td><code>just</code></td>
<td>
A string vector indicating how the layout should be
justified if it is not the same size as its parent viewport.
If there are two values, the first
value specifies horizontal justification and the second value specifies
vertical justification. Possible values are: <code>"left"</code>,
<code>"right"</code>, <code>"centre"</code>, <code>"center"</code>, <code>"bottom"</code>,
and <code>"top"</code>. NOTE that in this context,
<code>"left"</code>, for example, means align the left
edge of the left-most layout column with the left edge of the
parent viewport.</td></tr>
</table>
<h3>Details</h3>
<p>
The unit objects given for the <code>widths</code> and <code>heights</code>
of a layout may use a special <code>units</code> that only has
meaning for layouts. This is the <code>"null"</code> unit, which
indicates what relative fraction of the available width/height the
column/row occupies. See the reference for a better description
of relative widths and heights in layouts.
</p>
<h3>Value</h3>
<p>
A Grid layout object.</p>
<h3>WARNING</h3>
<p>
This function must NOT be confused with the base R graphics function
<code>layout</code>. In particular, do not use <code>layout</code> in
combination with Grid graphics. The documentation for
<code>layout</code> may provide some useful information and this
function should behave identically in comparable situations. The
<code>grid.layout</code>
function has <EM>added</EM> the ability to specify a broader range
of units for row heights and column widths, and allows for nested
layouts (see <code>viewport</code>).
</p>
<h3>Author(s)</h3>
<p>
Paul Murrell
</p>
<h3>References</h3>
<p>
Murrell, P. R. (1999), Layouts: A Mechanism for Arranging
Plots on a Page, <EM>Journal of Computational and Graphical
Statistics</EM>, <B>8</B>, 121–134.
</p>
<h3>See Also</h3>
<p>
<a href="Grid.html">Grid</a>,
<code><a href="grid.show.layout.html">grid.show.layout</a></code>,
<code><a href="viewport.html">viewport</a></code>,
<code><a href="../../graphics/html/layout.html">layout</a></code>
</p>
<h3>Examples</h3>
<pre>
## A variety of layouts (some a bit mid-bending ...)
layout.torture()
## Demonstration of layout justification
grid.newpage()
testlay <- function(just="centre") {
pushViewport(viewport(layout=grid.layout(1, 1, widths=unit(1, "inches"),
height=unit(0.25, "npc"),
just=just)))
pushViewport(viewport(layout.pos.col=1, layout.pos.row=1))
grid.rect()
grid.text(paste(just, collapse="-"))
popViewport(2)
}
testlay()
testlay(c("left", "top"))
testlay(c("right", "top"))
testlay(c("right", "bottom"))
testlay(c("left", "bottom"))
testlay(c("left"))
testlay(c("right"))
testlay(c("bottom"))
testlay(c("top"))
</pre>
<hr><div align="center">[Package <em>grid</em> version 2.5.1 <a href="00Index.html">Index]</a></div>
</body></html>