scale-y-time

Continuous y scale that formats axis labels as times of day.

Column values may be numeric seconds since midnight (an integer in [0, 86400)) or ISO-8601 strings of the form HH:MM[:SS].

Usage

scale-y-time(
  name: none,
  limits: none,
  oob: "drop",
  breaks: auto,
  labels: auto,
  expand: auto,
  date-format: "[hour]:[minute]",
)

Parameters

Parameter Default Description
name none Axis title. Overrides any name set via labels when both are present.
limits none Pair (lo, hi) clipping the trained domain (numeric seconds since the epoch or ISO-8601 strings; either side may be auto), or none for automatic limits.
oob "drop" Out-of-range policy: "drop" (default) removes rows whose value falls outside limits; "squish" clamps continuous values to the nearest endpoint.
breaks auto Array of break values (numeric seconds since the epoch or ISO-8601 strings), 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, where either element may be auto to keep the per-scale default on that side. auto keeps the per-scale default; false collapses to zero.
date-format "[hour]:[minute]" Typst datetime.display pattern used for break labels.

Returns

Scale object consumed by plot.

Examples

Time-of-day axis on the y for vertical event displays.

#let d = (
  (x: "Mon", y: "08:30"),
  (x: "Tue", y: "09:15"),
  (x: "Wed", y: "10:00"),
  (x: "Thu", y: "08:45"),
)
#plot(
  data: d,
  mapping: aes(x: "x", y: "y"),
  layers: (geom-point(size: 3pt),),
  scales: (scale-y-time(),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of four weekday events along a y axis showing hour-minute ticks decoded from HH:MM strings.

Scatter chart of four weekday events along a y axis showing hour-minute ticks decoded from HH:MM strings.

See also

scale-x-time, scale-y-datetime.

Back to top