label_number_si() is deprecated because the previous unit didn't actually
use SI units, but instead used the so called "short scale". You can now get the
same results as before with
label_number(scale_cut = cut_short_scale()), or if you want correct SI
units, label_number(scale_cut = cut_si("unit")).
label_number_si(unit = "", accuracy = NULL, scale = 1, suffix = "", ...)Unit of measurement (e.g. "m" for meter, the SI unit of length).
A number to round to. Use (e.g.) 0.01 to show 2 decimal
places of precision. If NULL, the default, uses a heuristic that should
ensure breaks have the minimum number of digits needed to show the
difference between adjacent values.
Applied to rescaled data.
A scaling factor: x will be multiplied by scale before
formatting. This is useful if the underlying data is already using an SI
prefix.
Additional text to display after the number.
Other arguments passed on to base::format().
All label_() functions return a "labelling" function, i.e. a function that
takes a vector x and returns a character vector of length(x) giving a
label for each input value.
Labelling functions are designed to be used with the labels argument of
ggplot2 scales. The examples demonstrate their use with x scales, but
they work similarly for all scales, including those that generate legends
rather than axes.
Other labels for continuous scales:
label_bytes(),
label_dollar(),
label_number_auto(),
label_ordinal(),
label_parse(),
label_percent(),
label_pvalue(),
label_scientific()
Other labels for log scales:
label_bytes(),
label_log(),
label_scientific()
# label_number_si() doesn't actually produce SI prefixes:
demo_continuous(c(1, 1e9), labels = label_number_si("g"))
#> scale_x_continuous(labels = label_number_si("g"))
#> Warning: `label_number_si()` was deprecated in scales 1.2.0.
#> Please use the `scale_cut` argument of `label_number()` instead.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.
# If you want real SI prefixes, use cut_si()
demo_continuous(c(1, 1e9), labels = label_number(scale_cut = cut_si("m")))
#> scale_x_continuous(labels = label_number(scale_cut = cut_si("m")))
# If you want the existing behavior, use cut_short_scale()
demo_continuous(c(1, 1e9), labels = label_number(scale_cut = cut_short_scale()))
#> scale_x_continuous(labels = label_number(scale_cut = cut_short_scale()))