This function relabels the facet strip labels in a plot created by a
wrap_* function (e.g., wrap_eta_cont(), wrap_cont_cont()) by looking
up the facet variable names in a named list or yspec object. Variable
names are discovered automatically from the plot data. Names absent from
spec and labs are left unchanged.
pmp_relabel_wrap(
p,
spec,
labs = list(),
short_max = Inf,
f_break = Inf,
unit_break = FALSE
)a ggplot object created by a wrap_* pmplots function.
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().
another object like spec containing of label data to override
names found in spec.
passed to yspec::ys_get_short_unit() when spec is a
yspec object.
character width at which to insert a single line break in
facet strip labels; defaults to Inf (no break); when the resolved label
exceeds this width, a single newline is inserted at the last word boundary
at or before the limit.
if TRUE, a newline is inserted between the label text and
a trailing parenthetical unit (e.g., "Weight (kg)" becomes
"Weight\n(kg)"); defaults to FALSE.
The plot p with updated facet strip labels.
data <- pmplots_data_obs()
spec <- list(WT = "Weight (kg)", ALB = "Albumin (mg/dL)")
p <- wrap_eta_cont(data, x = c("WT", "ALB"), y = "ETA1//ETA1", scales = "free_x")
pmp_relabel_wrap(p, spec)
#> `geom_smooth()` using formula = 'y ~ x'