Skip to contents

Add plot-level text — a title, subtitle, caption, and tag — and override the titles of individual axes and legends (x, y, color, fill, size). The title, subtitle, and tag are drawn in a band above the panels; the caption in a band below. Repeated labs() calls merge, with later values winning.

Usage

labs(
  plot,
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  tag = NULL,
  x = NULL,
  y = NULL,
  color = NULL,
  colour = NULL,
  fill = NULL,
  size = NULL,
  alt = NULL,
  ...
)

Arguments

plot

A PlotSpec.

title, subtitle, caption, tag

Plot-level text (or NULL to leave unset). In an animation, the title, subtitle and caption may embed frame variables such as "{closest_state}" or "{round(frame_time)}" (see Frame variables in animate()).

x, y, size

Axis / legend title overrides for those aesthetics.

color, colour

Colour-scale title override; colour is an alias for color.

fill

Fill-scale title override. color and fill are separate scales, so each takes its own title; give both the same title (and map the same variable) to draw them as one legend.

alt

A text alternative (alt text) describing the plot for screen readers and other assistive technology. Overrides the description vellumplot generates automatically; see plot_alt(). Emitted into the accessible SVG (<desc>) and tagged PDF (Figure Alt) by render_plot().

...

Reserved; passing anything here is an error.

Value

The modified PlotSpec.

Details

Axis/legend overrides set here are used unless a matching scale_*(name = ) is also given, which takes precedence. With neither, the title is derived from the mapping.

Examples

vplot(mtcars) |>
  mark_point(x = wt, y = mpg) |>
  labs(title = "Fuel economy", x = "Weight", y = "MPG")