scale-linewidth-binned

Binned continuous linewidth scale.

Maps a numeric column onto a stroke-thickness range, but groups values into n-breaks bins for the legend. The mapping stays continuous so drawn strokes vary smoothly within each bin; only the legend swatches snap to bin centres.

Usage

scale-linewidth-binned(
  n-breaks: 4,
  range: (0.4pt, 1.4pt),
  name: none,
  limits: none,
  labels: auto,
)

Parameters

Parameter Default Description
n-breaks 4 Number of legend bins.
range (0.4pt, 1.4pt) Pair of Typst lengths (min, max) bounding the output thickness.
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 breaks, or auto.

Returns

Scale object consumed by plot.

Examples

Linewidth grows with w, with the legend grouped into four bins.

#let d = range(0, 10).map(i => (x: i, y: i, w: i + 1, g: str(i)))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", linewidth: "w", group: "g"),
  layers: (geom-line(),),
  scales: (scale-linewidth-binned(n-breaks: 4, range: (0.4pt, 2pt)),),
  width: 10cm,
  height: 6cm,
)

Line chart of ten diagonal segments whose strokes thicken with w while the legend collapses into four stepped thickness bins.

Line chart of ten diagonal segments whose strokes thicken with w while the legend collapses into four stepped thickness bins.

See also

scale-linewidth-continuous, scale-size-binned.

Back to top