get_layout | R Documentation |
Get labels asigned to each panel of a tagged plot
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)
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. |
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.
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)` ..."
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.