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 beautoto train that side from the data;none(default) trains both sides.oob: Handling of rows outsidelimits:"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 (thebreaks-*helpers return such a function), orauto(default) for computed breaks. On the binnedlinetypeladder they are bin edges instead.minor-breaks: Array of minor-gridline positions in data units, a function of the trained values returning positions (thebreaks-*helpers return such a function), orauto(default) to subdivide the majors, halfway between them in transformed space.x/yonly.n-minor: Integer count of minor gridlines between adjacent majors, orauto(default) for one; ignored whenminor-breaksis set.x/yonly.labels: Array of labels aligned with the breaks, a function of the break value returning a string or content (theformat-*helpers return such a function), orauto(default) to format each break.transform:"identity"(default),"log10","sqrt", or"reverse".x/yonly.expand: Padding around the domain as a ratio (5%), a length (5pt), arelative, or a(lo, hi)pair whose sides may each beauto;falseornoneremoves it.auto(default) pads 5% per side.x/yonly.secondary: Secondary axis built withdup-axisorsec-axis, ornone(default).x/yonly.palette: Typst gradient or array of colours interpolated across the domain oncolour/fill, or an array of dash keywords onlinetype;auto(default) uses viridis and the built-in dash set respectively.range: Output(lo, hi)pair: lengths forsize(default(1pt, 6pt)),linewidth(default(0.4pt, 1.4pt)), andstroke(default(0.2pt, 1.4pt)); numbers in[0, 1]foralpha(default(0.1, 1)).n-breaks: Integer number of equal-width bins used whenbreaksisauto; default 4.linetypeonly.
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,
)