label-context

Labeller appending the row count for each level.

Produces a label of the form "<level> (n = <count>)" where <count> is the number of rows in the panel. The renderer supplies the count when it draws the strip.

Usage

label-context()

Returns

Labeller dictionary consumed by facet-wrap and facet-grid.

Examples

Strip text appends the per-panel row count.

#let d = ()
#for sp in ("a", "b") {
  for i in range(0, 4) {
    d.push((sp: sp, x: i, y: i))
  }
}
#plot(
  data: d,
  mapping: aes(x: "x", y: "y"),
  layers: (geom-point(size: 2pt),),
  facet: facet-wrap("sp", labeller: label-context()),
  width: 10cm,
  height: 5cm,
)

Two scatter panels faceted by sp with strip labels showing the level plus the row count, e.g., 'a (n = 4)'.

Two scatter panels faceted by sp with strip labels showing the level plus the row count, e.g., 'a (n = 4)'.

See also

label-value, label-both, labeller.

Back to top