scale-size-binned

Binned continuous size scale mapping a numeric column to n-breaks sizes.

Quantises the trained domain into equal-width bins so that all rows in a bin take the same visual size, drawn from the midpoint position of the range interval.

Usage

scale-size-binned(
  n-breaks: 4,
  range: (1pt, 6pt),
  name: none,
  limits: none,
  labels: auto,
)

Parameters

Parameter Default Description
n-breaks 4 Number of bins to partition the domain into.
range (1pt, 6pt) Pair of Typst lengths (min, max) bounding the output size.
name none Legend title. Overrides any name set via labs when both are present.
limits none Pair (lo, hi) clipping the trained domain, or none.
labels auto Array of legend labels aligned with the bins, or auto.

Returns

Scale object consumed by plot.

Examples

Four-bin discretisation across the default size range.

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

Scatter chart of twelve diagonal points where w is cut into four bins so markers snap to four distinct radii rather than vary smoothly.

Scatter chart of twelve diagonal points where w is cut into four bins so markers snap to four distinct radii rather than vary smoothly.

More bins (n-breaks: 8) on a wider range give finer steps while keeping the visual binning.

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

Scatter chart of twelve diagonal points where w is cut into eight bins across a wider 1pt to 12pt radius range for finer stepped marker sizes.

Scatter chart of twelve diagonal points where w is cut into eight bins across a wider 1pt to 12pt radius range for finer stepped marker sizes.

See also

scale-size-continuous, scale-size-binned-area.

Back to top