strip_themed | R Documentation |
A style of strips with individually themed strips.
strip_themed(
clip = "inherit",
size = "constant",
text_x = NULL,
text_y = NULL,
background_x = NULL,
background_y = NULL,
by_layer_x = FALSE,
by_layer_y = FALSE
)
clip |
A |
size |
A |
text_x , text_y |
A |
background_x , background_y |
A |
by_layer_x , by_layer_y |
A |
With respect to the text_*
and background_*
arguments, they can
be a list with (a mix of) the following objects:
NULL
indicates that the global plot theme applies.
element_blank()
omits drawing the background or text.
An element
class object inheriting from the element_text
or
element_rect
classes.
For constructing homogeneous lists of elements, the
elem_list_text()
and
elem_list_rect()
are provided for convenience.
A StripThemed
ggproto object that can be given as an argument to
facets in ggh4x.
Other strips:
strip_nested()
,
strip_split()
,
strip_vanilla()
# Some simple plot
p <- ggplot(mpg, aes(displ, hwy)) +
geom_point()
# Set some theming options, we can use `element_blank()`
backgrounds <- list(element_blank(), element_rect(fill = "dodgerblue"))
# Or we could use `NULL` to use the global theme
texts <- list(element_text(colour = "red"), NULL, element_text(face = "bold"))
# Elements are repeated until the fit the number of facets
p + facet_wrap2(
vars(drv, year),
strip = strip_themed(
background_x = backgrounds,
text_x = texts
)
)
# Except when applied to each layer instead of every strip
p + facet_wrap2(
vars(drv, year),
strip = strip_themed(
background_x = backgrounds,
text_x = texts,
by_layer_x = TRUE
)
)
# To conveniently distribute arguments over a list of the same elements,
# you can use the following wrappers:
p + facet_wrap2(
vars(drv, year),
strip = strip_themed(
text_x = elem_list_text(colour = c("blue", "red")),
background_x = elem_list_rect(fill = c("white", "grey80")),
by_layer_x = TRUE
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.