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

Description Usage Arguments Value Examples

View source: R/tag-facet.R

Description

Get labels asigned to each panel of a tagged plot

Usage

1
2
3
4
5
6
7
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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 Sept. 20, 2020, 4:56 a.m.