after-stat

Bind an aesthetic to a column produced by the layer’s stat, or to a per-row computation over the post-stat data.

expr may be a string column name (looked up in the post-stat row) or a function (row, ctx) => any. ctx carries theme, palette, stat-name, and stat-info (see _prepare-layer for the exact shape).

Usage

after-stat(
  expr,
)

Parameters

Parameter Default Description
expr Column-name string or (row, ctx) => any closure.

Returns

Late-binding marker consumed by aes.

Examples

Bind y to the _count column geom-bar’s stat-count publishes.

#let d = (
  (grp: "a"), (grp: "b"), (grp: "a"),
  (grp: "c"), (grp: "a"), (grp: "b"),
)
#plot(
  data: d,
  mapping: aes(x: "grp", y: after-stat("_count")),
  layers: (geom-bar(),),
  width: 10cm,
  height: 6cm,
)

Bar chart of three categories with bar heights bound to the post-stat _count column via after-stat.

Bar chart of three categories with bar heights bound to the post-stat _count column via after-stat.

See also

aes.

Back to top