scale-size-binned-area

Binned area-proportional size scale.

Combines binning with area scaling: the domain is partitioned into n-breaks bins, and the size of each bin grows with the square root of its normalised midpoint position.

Usage

scale-size-binned-area(
  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 area-proportional discretisation on a quadratic series.

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

Scatter chart of seven diagonal points where a quadratic w is cut into four bins and each bin sets marker area through the square-root mapping.

Scatter chart of seven diagonal points where a quadratic w is cut into four bins and each bin sets marker area through the square-root mapping.

Combine more bins with a wider range for a finer banded area scale on dense data.

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

Scatter chart of fifteen diagonal points where a quadratic w is cut into eight area-proportional bins across a wider 1pt to 16pt radius range.

Scatter chart of fifteen diagonal points where a quadratic w is cut into eight area-proportional bins across a wider 1pt to 16pt radius range.

See also

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

Back to top