scale-date
Temporal position scale formatting axis labels as dates (x or y).
Column values may be numeric days since 2000-01-01 or ISO-8601 YYYY-MM-DD strings.
Usage
scale-date(
..args,
)Parameters
| Parameter | Default | Description |
|---|---|---|
..args |
Named arguments forwarded to the axis 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 of numbers or ISO-8601 strings, 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 the scale’s numeric 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.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.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.date-format: Typstdatetime.displayformat string; default"[year]-[month repr:numerical]-[day]".
Returns
Deferred scale spec consumed by scales.
Examples
Format an x axis of numeric days since 2000-01-01 as year-month ticks.
#let d = range(0, 12).map(i => (x: 8766 + 30 * i, y: i))
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (geom-line(), geom-point(size: 2pt)),
scales: scales(x: scale-date(date-format: "[year]-[month repr:numerical]")),
width: 12cm,
height: 6cm,
)