# 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
)
)
Run the code above in your browser using DataLab