scale-linewidth-continuous

Continuous linewidth scale mapping a numeric column to stroke thickness.

Usage

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

Parameters

Parameter Default Description
name none Legend title. Overrides any name set via labs when both are present.
range (0.4pt, 1.4pt) Pair of Typst lengths (min, max) bounding the output thickness.
limits none Pair (lo, hi) clipping the trained domain, or none.
breaks auto Array of break values for the legend, or auto.
labels auto Array of legend labels aligned with breaks, or auto.

Returns

Scale object consumed by plot.

Examples

Linewidth grows with w, with one segment per row driven by the group mapping.

#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-continuous(range: (0.4pt, 2pt)),),
  width: 10cm,
  height: 6cm,
)

Line chart of ten diagonal segments where each segment's stroke thickness scales continuously with w from a thin to a thick stroke.

Line chart of ten diagonal segments where each segment's stroke thickness scales continuously with w from a thin to a thick stroke.

Pair colour and linewidth with the same column to encode magnitude through both channels.

#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", colour: "w", linewidth: "w", group: "g"),
  layers: (geom-line(),),
  scales: (scale-linewidth-continuous(range: (0.4pt, 3pt)),),
  width: 10cm,
  height: 6cm,
)

Line chart of ten diagonal segments where w encodes both stroke thickness and colour so magnitude grows redundantly through both channels.

Line chart of ten diagonal segments where w encodes both stroke thickness and colour so magnitude grows redundantly through both channels.

See also

scale-linewidth-identity, scale-size-continuous.

Back to top