scale-y-date

Continuous y scale that formats axis labels as dates.

Column values may be numeric days since 2000-01-01 or ISO-8601 strings of the form YYYY-MM-DD.

Usage

scale-y-date(
  name: none,
  limits: none,
  breaks: auto,
  labels: auto,
  expand: auto,
  date-format: "[year]-[month repr:numerical]-[day]",
)

Parameters

Parameter Default Description
name none Axis title. Overrides any name set via labs when both are present.
limits none Pair (lo, hi) clipping the trained domain (in days), or none for automatic limits.
breaks auto Array of break values (in days), or auto for automatic tick selection.
labels auto Array of tick labels aligned with breaks, or auto.
expand auto Padding around the domain. Accepts a ratio (5%) for proportional breathing room, a length (5pt) for canvas-space padding, a relative (5pt + 5%) for both, or a (lo, hi) 2-tuple for asymmetric padding. auto keeps the per-scale default; false collapses to zero.
date-format "[year]-[month repr:numerical]-[day]" Typst datetime.display pattern used for break labels.

Returns

Scale object consumed by plot.

Examples

Date axis on the y, useful for horizontal bar charts of time-stamped events.

#let d = (
  (label: "Alpha", y: "2024-01-15"),
  (label: "Beta",  y: "2024-03-01"),
  (label: "Gamma", y: "2024-05-20"),
)
#plot(
  data: d,
  mapping: aes(x: "label", y: "y"),
  layers: (geom-point(size: 4pt),),
  scales: (scale-y-date(date-format: "[month repr:short] [day]"),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of three labelled events along a y axis showing month-day ticks decoded from ISO-8601 date strings.

Scatter chart of three labelled events along a y axis showing month-day ticks decoded from ISO-8601 date strings.

See also

scale-x-date, scale-y-datetime.

Back to top