
Last chance! 50% off unlimited learning
Sale ends in
grid.layout(nrow = 1, ncol = 1, widths = unit(rep_len(1, ncol), "null"), heights = unit(rep_len(1, nrow), "null"), default.units = "null", respect = FALSE, just="centre")
widths
or heights
are only given as numeric vectors."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.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
).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.
grid.show.layout
,
viewport
,
layout
## 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"))
Run the code above in your browser using DataLab