scale-shape-binned

Binned shape scale: cuts a continuous variable into n-breaks bins, each bin gets one shape from palette.

The scale stays continuous: the trained domain is numeric and the resolver snaps each row to the bin its value falls into. The legend renders one glyph per bin at the midpoint.

Usage

scale-shape-binned(
  n-breaks: 4,
  palette: auto,
  name: none,
  limits: none,
  labels: auto,
)

Parameters

Parameter Default Description
n-breaks 4 Number of bins to partition the continuous domain into.
palette auto Array of shape keywords, one per bin, or auto for the library default.
name none Legend title. Overrides any name set via labs when both are present.
limits none Continuous (lo, hi) pair pinning the domain, or none.
labels auto Array of legend labels aligned with bin midpoints, or auto.

Returns

Scale object consumed by plot.

Examples

Bin a continuous score column into four shape buckets.

#let d = range(0, 12).map(i => (x: i, y: i, w: i + 1))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", shape: "w"),
  layers: (geom-point(size: 3pt),),
  scales: (scale-shape-binned(n-breaks: 4),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of twelve diagonal points where the continuous w column is cut into four bins, each mapped to a distinct marker glyph.

Scatter chart of twelve diagonal points where the continuous w column is cut into four bins, each mapped to a distinct marker glyph.

See also

scale-shape, scale-shape-manual, geom-point.

Back to top