Splits the data by one or more variables and lays the resulting panels out in a rectangular grid, wrapping to a new row as needed.

facet_wrap(vars, ncol = NULL, nrow = NULL, scales = "fixed")

Arguments

vars

Faceting variables: unquoted names (facet_wrap(cyl)), a character vector, or several names.

ncol, nrow

Force a panel-grid shape; NULL picks a near-square layout.

scales

"fixed" (all panels share axes — best for comparison), "free_x", "free_y", or "free" (each panel scales to its own data).

Value

A Facet object to add to a plot with +.

Examples

ggnext(iris, aes(Sepal.Length, Sepal.Width)) +
  geom_point() +
  facet_wrap(Species)
#> <ggnext plot>
#>   data:  150 x 5
#>   aes:   x = Sepal.Length, y = Sepal.Width
#>   layers: 1 
#>   coord: cartesian
#>   mode:  static