facet_wrap() lays panels out in a ribbon wrapped into ncol/nrow;
facet_grid() arranges them on a 2-D grid defined by a rows ~ cols
formula. Position scales are shared across panels by default (so axes align);
pass scales = "free_x", "free_y", or "free" to train them per panel.
Colour and size scales (and their legends) are always shared in this version.
Arguments
- plot
A PlotSpec.
- facets
A faceting formula. For
facet_wrap(), one-sided such as~ cyl(one or more+-separated variables); forfacet_grid(), a two-sidedrows ~ cols(use.for no faceting on a side).- ncol, nrow
Number of columns/rows for
facet_wrap().- scales
One of
"fixed"(default),"free_x","free_y","free".
Value
The modified PlotSpec.
Examples
vplot(mtcars) |> mark_point(x = wt, y = mpg) |> facet_wrap(~cyl)
vplot(mtcars) |> mark_point(x = wt, y = mpg) |> facet_grid(am ~ cyl)
