facet_nested | R Documentation |
facet_nested()
forms a matrix of panels defined by row
and column faceting variables and nests grouped facets.
facet_nested(
rows = NULL,
cols = NULL,
scales = "fixed",
space = "fixed",
axes = "margins",
remove_labels = "none",
independent = "none",
shrink = TRUE,
labeller = "label_value",
as.table = TRUE,
switch = NULL,
drop = TRUE,
margins = FALSE,
nest_line = element_line(inherit.blank = TRUE),
solo_line = FALSE,
resect = unit(0, "mm"),
render_empty = TRUE,
strip = strip_nested(),
bleed = NULL
)
This function inherits the capabilities of
facet_grid2()
.
Unlike facet_grid()
, this function only automatically expands
missing variables when they have no variables in that direction, to allow
for unnested variables. It still requires at least one layer to have all
faceting variables.
Hierarchies are inferred from the order of variables supplied to
rows
or cols
. The first variable is interpreted to be the
outermost variable, while the last variable is interpreted to be the
innermost variable. They display order is always such that the outermost
variable is placed the furthest away from the panels. For more information
about the nesting of strips, please visit the documentation of
strip_nested()
.
A FacetNested ggproto object that can be added to a plot.
See strip_nested()
for nested strips. See
ggplot2::facet_grid()
for descriptions of the original
arguments. See grid::unit()
for the construction of a
unit
vector.
Other facetting functions:
facet_grid2()
,
facet_manual()
,
facet_nested_wrap()
,
facet_wrap2()
# A standard plot
p <- ggplot(mtcars, aes(mpg, wt)) +
geom_point()
# Similar to `facet_grid2(..., strip = strip_nested())`
p + facet_nested(~ vs + cyl)
# The nest line inherits from the global theme
p + facet_nested(~ cyl + vs, nest_line = element_line(colour = "red")) +
theme(ggh4x.facet.nestline = element_line(linetype = 3))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.