This strip style renders the strips as text with fitted boxes onto the panels of the plot. This is in contrast to strips that match the panel size and are located outside the panels.
Usage
strip_tag(
clip = "inherit",
order = c("x", "y"),
just = c(0, 1),
text_x = NULL,
text_y = element_text(angle = 0),
background_x = NULL,
background_y = NULL,
by_layer_x = FALSE,
by_layer_y = FALSE
)
Arguments
- clip
A
character(1)
that controls whether text labels are clipped to the background boxes. Can be either"inherit"
(default),"on"
or"off"
.- order
Either
c("x", "y")
orc("y", "x")
, setting the top-to-bottom order of horizontal versus "vertical" labels in facets with a grid layout.- just
A
<numeric[2]>
setting the horizontal and vertical justification of placing the textbox.- text_x, text_y
A
list()
withelement_text()
elements. See details.- background_x, background_y
A
list()
withelement_rect()
elements. See details.- by_layer_x, by_layer_y
A
logical(1)
that whenTRUE
, maps the different elements to different layers of the strip. WhenFALSE
, maps the different elements to individual strips, possibly repeating the elements to match the number of strips throughrep_len()
.
See also
Other strips:
strip_nested()
,
strip_split()
,
strip_themed()
,
strip_vanilla()
Examples
# A standard plot
p <- ggplot(mpg, aes(displ, hwy)) +
geom_point()
# Typical use
p + facet_wrap2(
~ class,
strip = strip_tag()
)
# Adjusting justification
p + facet_wrap2(
~ class,
strip = strip_tag(just = c(1, 0))
)
p + facet_wrap2(
~ drv + year,
strip = strip_tag()
)
# With a grid layout, you can control in which order the labels are drawn
p + facet_grid2(
"vertical" ~ "horizontal",
strip = strip_tag(order = c("x", "y")) # default
)
p +facet_grid2(
"vertical" ~ "horizontal",
strip = strip_tag(order = c("y", "x")) # invert order
)