scale-y-binned

Binned continuous y scale: quantises a numeric axis into n-breaks bins.

Counterpart of scale-x-binned for the y axis.

Usage

scale-y-binned(
  name: none,
  limits: none,
  n-breaks: 10,
  labels: auto,
)

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, or none.
n-breaks 10 Number of bins to partition the domain into.
labels auto Array of tick labels aligned with the bin midpoints, or auto.

Returns

Scale object consumed by plot.

Examples

Five equal-width bins along the y axis.

#let d = range(0, 30).map(i => (x: i, y: i / 3.0))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y"),
  layers: (geom-point(size: 2pt),),
  scales: (scale-y-binned(n-breaks: 5),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of thirty diagonal points along a y axis cut into five equal-width bins whose midpoints place the tick labels.

Scatter chart of thirty diagonal points along a y axis cut into five equal-width bins whose midpoints place the tick labels.

A finer ten-bin partition with limits clipping the lower tail.

#let d = range(0, 30).map(i => (x: i, y: i / 3.0))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y"),
  layers: (geom-point(size: 2pt),),
  scales: (scale-y-binned(n-breaks: 10, limits: (2, 9)),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of thirty diagonal points along a y axis cut into ten finer bins and clipped to limits 2 through 9 to drop the lower tail.

Scatter chart of thirty diagonal points along a y axis cut into ten finer bins and clipped to limits 2 through 9 to drop the lower tail.

See also

scale-x-binned, scale-y-continuous.

Back to top