get_layout: Get labels asigned to each panel of a tagged plot

View source: R/tag-facet.R

get_layoutR Documentation

Get labels asigned to each panel of a tagged plot

Description

Get labels asigned to each panel of a tagged plot

Usage

get_layout(plot = ggplot2::last_plot())

get_tag(filter = TRUE, plot = ggplot2::last_plot(), n = 1)

get_row(filter = TRUE, plot = ggplot2::last_plot(), n = 1)

get_col(filter = TRUE, plot = ggplot2::last_plot(), n = 1)

Arguments

plot

a plot object

filter

an expression that, evaluated within the data used to generate the facets of the plot, evaluates to a logical vector or a sequence of rows.

n

number of expected panels.

Value

get_tags(), get_row() and get_col() return a character vector of length n with the tags, unique rows or unique columns that meet the filter condition.

get_layout() returns the full data.frame describing the panel layout.

Examples

library(ggplot2)
g <- ggplot(mtcars, aes(hp, mpg)) +
  geom_point() +
  facet_grid(cyl ~ vs) +
  tag_facets("rc")

# By default these functions retrieve tags from
# the result of ggplo2::last_plot().

# Get all tags
get_layout()

# Get one tag
get_tag(cyl == 4 & vs == 0)

# Get more than one tag
get_tag(cyl == 4, n = 2)


get_row(cyl == 4)
get_col(vs == 0)

# Use it with inline markdown to refer always to the correct panel:
# "As you can see in panel `r get_tag(cyl == 4 & vs == 0)` ..."


eliocamp/tagger documentation built on Jan. 4, 2024, 9:50 a.m.