breaks-pretty
Round breaks at roughly the requested count.
Since 0.6.0.
Picks positions of the form c * 10^k for c in 1, 2, 5, the same algorithm the automatic breaks use, so n is a target rather than a guarantee. Whole-number data keeps whole breaks. The counterpart of scales::breaks_pretty().
Usage
breaks-pretty(
n: 5,
)Parameters
| Parameter | Default | Description |
|---|---|---|
n |
5 |
Target number of intervals; the tick count lands near n + 1. |
Returns
Closure taking the trained values and returning break positions.
Examples
Two intervals instead of the default five.
#plot(
data: mpg,
mapping: aes(x: "displ", y: "hwy"),
layers: (geom-point(),),
scales: scales(x: scale-continuous(breaks: breaks-pretty(n: 2))),
width: 10cm,
height: 6cm,
)