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 (e.g. name, limits, breaks, labels, expand, date-format).

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,
)

Line-and-point chart of twelve rising values on an x axis showing year-month ticks decoded from numeric days since 2000-01-01.

Line-and-point chart of twelve rising values on an x axis showing year-month ticks decoded from numeric days since 2000-01-01.

See also

scales, scale-datetime, scale-time.

Back to top