Skip to contents

Places a smaller plot (inset) as a floating panel on top of a base plotit via patchwork::inset_element(). Position is specified in normalised parent coordinates (0-1 relative to the panel or plot area). The returned composite accepts label_title() / style() / export() in the usual way.

Usage

compose_inset(
  base,
  inset,
  left = 0,
  bottom = 0,
  right = 1,
  top = 1,
  align_to = "panel",
  on_top = TRUE,
  ...
)

Arguments

base

A plotit object serving as the background.

inset

A plotit or plotit_composite object to overlay.

left, right, bottom, top

Inset edges in npc (0-1).

align_to

Coordinate reference: "panel" (default) or "plot".

on_top

Logical; TRUE (default) = inset rendered above base.

...

Passed through to patchwork::inset_element().

Value

A plotit_composite object.

Examples

p1 <- plotit(mtcars, encode(x = wt, y = mpg)) |> mark_point()
p2 <- plotit(mtcars, encode(x = factor(cyl))) |> mark_bar()
compose_inset(p1, p2, left = 0.6, bottom = 0.6, right = 0.95, top = 0.95)