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,
  breaks: auto,
  palette: auto,
  name: none,
  limits: none,
  oob: "drop",
  labels: auto,
)

Parameters

Parameter Default Description
n-breaks 4 Number of bins to partition the continuous domain into. Ignored when breaks is set.
breaks auto Array of bin edges, or auto to derive equal-width bins from n-breaks. Edges define the bin boundaries; n-breaks is ignored when set.
palette auto Array of shape keywords, one per bin, or auto for the library default.
name none Legend title. Overrides any name set via labels when both are present.
limits none Continuous (lo, hi) pair pinning the domain, or none.
oob "drop" Out-of-range policy: "drop" (default) removes rows whose value falls outside limits; "squish" clamps continuous values to the nearest endpoint.
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