scale-continuous

Continuous scale for any continuous aesthetic.

Keyed to x/y it controls the axis (limits, breaks, transform, expand, secondary); keyed to colour/fill it sets the palette; keyed to size/alpha/linewidth/stroke it sets the output range.

Usage

scale-continuous(
  ..args,
)

Parameters

Parameter Default Description
..args Named arguments forwarded to the bound scale.

Keys accepted by ..args:

  • name: Axis or legend title, as a string or content; none (default) falls back to the mapped column name.
  • limits: Domain as a (lo, hi) pair, where either side may be auto to train that side from the data; none (default) trains both sides.
  • oob: Handling of rows outside limits: "drop" (default) removes them, "squish" clamps them to the nearest limit.
  • breaks: Array of tick positions in data units, a bare number for a single tick, a function of the trained values returning positions (the breaks-* helpers return such a function), or auto (default) for computed breaks. On the binned linetype ladder they are bin edges instead.
  • minor-breaks: Array of minor-gridline positions in data units, a function of the trained values returning positions (the breaks-* helpers return such a function), or auto (default) to subdivide the majors, halfway between them in transformed space. x/y only.
  • n-minor: Integer count of minor gridlines between adjacent majors, or auto (default) for one; ignored when minor-breaks is set. x/y only.
  • labels: Array of labels aligned with the breaks, a function of the break value returning a string or content (the format-* helpers return such a function), or auto (default) to format each break.
  • transform: "identity" (default), "log10", "sqrt", or "reverse". x/y only.
  • expand: Padding around the domain as a ratio (5%), a length (5pt), a relative, or a (lo, hi) pair whose sides may each be auto; false or none removes it. auto (default) pads 5% per side. x/y only.
  • secondary: Secondary axis built with dup-axis or sec-axis, or none (default). x/y only.
  • palette: Typst gradient or array of colours interpolated across the domain on colour/fill, or an array of dash keywords on linetype; auto (default) uses viridis and the built-in dash set respectively.
  • range: Output (lo, hi) pair: lengths for size (default (1pt, 6pt)), linewidth (default (0.4pt, 1.4pt)), and stroke (default (0.2pt, 1.4pt)); numbers in [0, 1] for alpha (default (0.1, 1)).
  • n-breaks: Integer number of equal-width bins used when breaks is auto; default 4. linetype only.

Returns

Deferred scale spec consumed by scales.

Examples

Pin the x domain and rename the axis with a continuous scale.

#let d = range(1, 11).map(i => (x: i, y: i * i))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y"),
  layers: (geom-point(size: 2pt),),
  scales: scales(x: scale-continuous(name: "Index", limits: (0, 12))),
  width: 10cm,
  height: 6cm,
)

Scatter chart of ten squared values with the x axis renamed to Index and pinned to the range 0 through 12.

Scatter chart of ten squared values with the x axis renamed to Index and pinned to the range 0 through 12.

See also

scales, scale-discrete, scale-binned.

Back to top