Applies pm_gg_labs() to a ggplot object, patchwork object, or a list of ggplot objects, updating axis and aesthetic labels by looking up column names in a named list or yspec object.

pm_relabel(x, ...)

# S3 method for class 'gg'
pm_relabel(x, spec, labs = list(), ...)

# S3 method for class 'patchwork'
pm_relabel(x, spec, labs = list(), ...)

# S3 method for class 'list'
pm_relabel(x, spec, labs = list(), ...)

Arguments

x

a gg object, a patchwork object (e.g., from eta_covariate() or npde_panel()), or a list of ggplot objects.

...

additional arguments passed to pm_gg_labs().

spec

a named list of label data; names correspond to columns in the data used to make the plot; may also be a yspec object, which will be converted to a named list through yspec::ys_get_short_unit().

labs

another object like spec containing of label data to override names found in spec.

Details

Methods are provided for gg objects (single plots), patchwork objects (multi-panel layouts produced by functions such as eta_covariate() or npde_panel()), and plain list objects containing ggplot objects. The patchwork method applies the relabeling to every panel in the layout using the & operator.

Examples

data <- pmplots_data_obs()

spec <- list(
  DV = "CX1123 concentration (ng/mL)",
  PRED = "Population prediction (ng/mL)"
)

p <- dv_pred(data)

pm_relabel(p, spec)
#> `geom_smooth()` using formula = 'y ~ x'