facet-grid
Grid facets: panels on a row x column grid from two discrete variables.
Either rows or columns may be none, but not both. Only shared scales are supported in v1.
Usage
facet-grid(
rows: none,
columns: none,
scales: "fixed",
labeller: label-value(),
)Parameters
| Parameter | Default | Description |
|---|---|---|
rows |
none |
Name of the discrete column driving panel rows, or none. |
columns |
none |
Name of the discrete column driving panel columns, or none. |
scales |
"fixed" |
Scale policy. Only "fixed" is supported in v1. |
labeller |
label-value() |
Labeller controlling strip text. Defaults to label-value() which shows the level as-is. |
Returns
Facet dictionary consumed by plot.
Examples
Two discrete variables driving the row and column structure.
#let d = ()
#for sp in ("a", "b") {
for sex in ("F", "M") {
for i in range(0, 5) {
d.push((sp: sp, sex: sex, x: i, y: i + 1))
}
}
}
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (geom-point(size: 2pt),),
facet: facet-grid(rows: "sex", columns: "sp"),
width: 12cm,
height: 7cm,
)Pass only rows: (or only columns:) for a one-dimensional grid layout.
#let d = ()
#for sex in ("F", "M") {
for i in range(0, 6) {
d.push((sex: sex, x: i, y: i * 1.5))
}
}
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (geom-point(size: 2pt),),
facet: facet-grid(rows: "sex"),
width: 12cm,
height: 7cm,
)