scale-stroke-binned

Binned continuous stroke scale.

Maps a numeric column onto an outline-thickness range, but groups values into n-breaks bins for the legend.

Usage

scale-stroke-binned(
  n-breaks: 4,
  breaks: auto,
  range: (0.2pt, 1.4pt),
  name: none,
  limits: none,
  oob: "drop",
  labels: auto,
)

Parameters

Parameter Default Description
n-breaks 4 Number of legend bins. Ignored when breaks is set.
breaks auto Array of bin edges for the legend, or auto to derive equal-width bins from n-breaks. Affects the legend only; the per-row mapping stays continuous.
range (0.2pt, 1.4pt) Pair of Typst lengths (min, max) bounding the output thickness.
name none Legend title.
limits none Pair (lo, hi) clipping the trained 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 breaks, or auto.

Returns

Scale object consumed by plot.

Examples

Bucket a continuous w column into three thickness bands while still feeding a numeric range to the scale.

#let d = range(1, 13).map(i => (x: i, y: i, w: i))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", stroke: "w"),
  layers: (geom-point(size: 5pt, fill: rgb("#1f77b4")),),
  scales: (scale-stroke-binned(n-breaks: 3, range: (0.2pt, 1.6pt)),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of twelve blue markers along the diagonal where outline thickness steps through three bins drawn from the binned stroke palette.

Scatter chart of twelve blue markers along the diagonal where outline thickness steps through three bins drawn from the binned stroke palette.

See also

scale-stroke-continuous, scale-linewidth-binned.

Back to top