Learn R Programming

ggplot2 (version 4.0.1)

get_strip_labels: Accessing a plot's facet strip labels

Description

This functions retrieves labels from facet strips with the labeller applied.

Usage

get_strip_labels(plot = get_last_plot())

Value

NULL if there are no labels, otherwise a list of data.frames containing the labels.

Arguments

plot

A ggplot or build ggplot object.

Examples

Run this code
# Basic plot
p <- ggplot(mpg, aes(displ, hwy)) +
  geom_point()

get_strip_labels(p) # empty facets
get_strip_labels(p + facet_wrap(year ~ cyl))
get_strip_labels(p + facet_grid(year ~ cyl))

Run the code above in your browser using DataLab