Expand description
Label formatting functions for scale breaks.
Analogous to R’s scales package (comma, percent, dollar, scientific,
number, SI, ordinal, bytes).
Functions§
- label_
bytes - Byte-size formatter.
binary = trueuses 1024-based KiB/MiB; otherwise 1000-based kB/MB. - label_
comma - Format with comma separators for thousands (e.g., 1,234,567).
- label_
currency - Sign-aware currency formatter (R’s
scales::label_currency): the minus sign goes before the prefix (“-€5”, not “€-5”), thousands are grouped withbig_mark(e.g.",","."," ","'";""disables grouping), andaccuracyrounds to a multiple of it (None= up to two decimals, trailing zeros trimmed). The decimal mark is always.. - label_
dollar - Format as US dollar with thousands separators (e.g., 1234 → “$1,234”,
-500 → “-$500”). Equivalent to
label_currency("$", "", ",", None). - label_
number - General configurable number formatter (R’s
scales::label_number). Multiplies byscale, rounds toaccuracy(None = trim), groups thousands with,, and wraps inprefix/suffix— with the minus sign placed before the prefix (-€5). For a custom thousands mark uselabel_currency. - label_
ordinal - Ordinal formatter: 1 → “1st”, 2 → “2nd”, 3 → “3rd”, 11 → “11th”.
- label_
percent - Format as percentage (e.g., 0.5 → “50%”).
- label_
scientific - Format in scientific notation (e.g., 12345 → “1.23e4”).
- label_
si - SI-prefixed number formatter: 1_500 → “1.5k”, 2.3e6 → “2.3M”, 5e-4 → “500µ”.
Type Aliases§
- Label
Formatter - A label formatter — any
Fn(f64) -> String. The plainlabel_*functions coerce into this, and the configurablelabel_number/label_si/… builders return one directly.