An integer describing the number of rows in the layout.
ncol
An integer describing the number of columns in the layout.
widths
A numeric vector or unit object
describing the widths of the columns
in the layout.
heights
A numeric vector or unit object
describing the heights of the rows
in the layout.
default.units
A string indicating the default units to use
if widths or heights are only given as numeric vectors.
respect
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).
just
A string or numeric
vector specifying 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 string values are: "left",
"right", "centre", "center", "bottom",
and "top". For numeric values, 0 means left alignment
and 1 means right alignment. NOTE that in this context,
"left", for example, means align the left
edge of the left-most layout column with the left edge of the
parent viewport.
Details
The unit objects given for the widths and heights
of a layout may use a special units that only has
meaning for layouts. This is the "null" 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.
Value
A Grid layout object.
WARNING
This function must NOT be confused with the base R graphics function
layout. In particular, do not use layout in
combination with Grid graphics. The documentation for
layout may provide some useful information and this
function should behave identically in comparable situations. The
grid.layout
function has added the ability to specify a broader range
of units for row heights and column widths, and allows for nested
layouts (see viewport).
Author(s)
Paul Murrell
References
Murrell, P. R. (1999), Layouts: A Mechanism for Arranging
Plots on a Page, Journal of Computational and Graphical
Statistics, 8, 121–134.
See Also
Grid,
grid.show.layout,
viewport,
layout
Examples
## 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"),
heights=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"))
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(grid)
> png(filename="/home/ddbj/snapshot/RGM3/R_rel/result/grid/grid.layout.Rd_%03d_medium.png", width=480, height=480)
> ### Name: grid.layout
> ### Title: Create a Grid Layout
> ### Aliases: grid.layout
> ### Keywords: dplot
>
> ### ** Examples
>
> ## 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"),
+ heights=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"))
>
>
>
>
>
> dev.off()
null device
1
>