facet_grid(rows, cols) builds a two-way panel matrix: one row per level of rows, one column per level of cols.

facet_grid(rows, cols = NULL, scales = "fixed")

Arguments

rows

Variable defining the panel rows (unquoted name or string).

cols

Variable defining the panel columns; NULL for a single column.

scales

As in facet_wrap().

Value

A Facet object to add to a plot with +.

Examples

d <- transform(mtcars, cyl = factor(cyl), am = factor(am))
ggnext(d, aes(disp, mpg)) + geom_point() + facet_grid(am, cyl)
#> <ggnext plot>
#>   data:  32 x 11
#>   aes:   x = disp, y = mpg
#>   layers: 1 
#>   coord: cartesian
#>   mode:  static