Create an inset with page size dimensions be added on top of the previous plot
Source:R/inset_page_element.R
inset_page_element.RdCreate an inset with page size dimensions be added on top of the previous plot
Usage
inset_page_element(
p,
inset_page = NULL,
left = NULL,
bottom = NULL,
right = NULL,
top = NULL,
align_to = "panel",
on_top = TRUE,
clip = TRUE,
ignore_tag = FALSE,
...
)Arguments
- p
A grob, ggplot, patchwork, formula, raster, or nativeRaster object to add as an inset
- inset_page
Page size data.frame to use for inset, Default:
NULL- left, bottom, right, top
numerics or units giving the location of the outer bounds. If given as numerics and inset_page is NULL, they will be converted to npc units. All four are required if inset_page is
NULL. If inset_page is provided, top or bottom and left or right must be provided as the inset element is expected to be the width and height defined by inset_page.- align_to
Specifies what
left,bottom, etc should be relative to. Either'panel'(default),'plot', or'full'.- on_top
Logical. Should the inset be placed on top of the other plot or below (but above the background)?
- clip
Logical. Should clipping be performed on the inset?
- ignore_tag
Logical. Should autotagging ignore the inset?
- ...
Arguments passed on to
convert_unit_typefromUnit to convert from. If
NULLand x is not a units object, convert totounits with a warning.toUnit to convert to. Passed to unitTo parameter of
grid::convertUnit(). IfNULL, return x as is.typeFromPassed to typeFrom parameter of
grid::convertUnit(). Defaults to "dimension".valueOnlyPassed to valueOnly parameter of
grid::convertUnit(). Defaults toFALSE.xA numeric vector.
For
is.unit, any R object.
Examples
if (FALSE) { # \dontrun{
if (interactive() && is_installed("ggplot2")) {
library(ggplot2)
p <- ggplot(mpg, aes(displ, fill = class)) +
geom_bar()
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point() +
inset_page_element(
p = p,
inset_page = get_page_size("Poker card", orientation = "landscape"),
left = unit(1, "in"),
bottom = unit(1, "in")
)
}
} # }