apply_default_labs: Apply default label overrides to a plot

View source: R/xtra_labs.R

apply_default_labsR Documentation

Apply default label overrides to a plot

Description

Resolves title/subtitle/caption/tag labels for plot from (in increasing precedence):

  1. the xpose.xtras.default_labs R option (a named list, see examples),

  2. defaults set on xpdb via set_default_labs(), when xpdb is supplied (a rendered plot does not retain enough of its source xpdb to look this up automatically – pass it explicitly),

  3. values passed directly via ....

By default only labels not already set on the plot are filled in; set overwrite = TRUE to replace existing labels too. print.xpose_plot() calls this automatically whenever xpose.xtras.auto_apply is enabled (the default; see set_xtras_options()), but apply_default_labs() itself is a standalone function that doesn't depend on that print method existing, so it works the same regardless of whether that method survives issue #36's eventual removal.

Usage

apply_default_labs(plot, ..., xpdb = NULL, overwrite = FALSE)

Arguments

plot

<ggplot> or <xpose_plot> object

...

<dynamic-dots> Direct overrides for title/subtitle/caption/tag, taking precedence over both the option- and xpdb-level defaults

xpdb

<xpose_data> or <xp_xtras> object plot was built from, used to resolve xpdb-level defaults (see set_default_labs()) and to resolve ⁠@keyword⁠ placeholders in any of the labels. If omitted and plot is an xpose_plot, ⁠@keyword⁠ placeholders are still resolved (using the reduced context xpose attaches to the plot) but xpdb-level defaults are not available

overwrite

<logical> Replace labels already present on plot (default FALSE, meaning only missing labels are filled in)

Value

plot, with resolved labels applied

See Also

set_xtras_options() for the full list of ⁠xpose.xtras.*⁠ session options, and get_xtras_option() to check which tier (option/xpdb) is currently dominant for a given xpdb.

Examples

options(xpose.xtras.default_labs = list(caption = "Draft -- do not distribute"))
p <- xpose::dv_vs_ipred(xpose::xpdb_ex_pk)
apply_default_labs(p)
options(xpose.xtras.default_labs = NULL)

xpose.xtras documentation built on Sept. 1, 2026, 5:08 p.m.