R/recycle-gpar.R

Defines functions unit_to_list recycle_gpar

# takes a graphical parameters object gp and returns a list of
# length n of appropriately recycled elements from gp
recycle_gpar <- function(gp = NULL, n = 1) {
  make_gpar <- function(n, ...) {
    structure(
      list(...),
      class = "gpar"
    )
  }

  args <- c(list(make_gpar, n = 1:n), gp, list(SIMPLIFY = FALSE))
  do.call(mapply, args)
}

# converts a unit vector into a list of individual unit objects
unit_to_list <- function(u)
{
  lapply(seq_along(u), function(i) u[i])
}

Try the gridtext package in your browser

Any scripts or data that you put into this service are public.

gridtext documentation built on Sept. 16, 2022, 5:07 p.m.