cbreaks: Compute breaks for continuous scale

View source: R/breaks-retired.R

cbreaksR Documentation

Compute breaks for continuous scale

Description

[Superseded]

This function wraps up the components needed to go from a continuous range to a set of breaks and labels suitable for display on axes or legends.

Usage

cbreaks(range, breaks = extended_breaks(), labels = scientific_format())

Arguments

range

numeric vector of length 2 giving the range of the underlying data

breaks

either a vector of break values, or a break function that will make a vector of breaks when given the range of the data

labels

either a vector of labels (character vector or list of expression) or a format function that will make a vector of labels when called with a vector of breaks. Labels can only be specified manually if breaks are - it is extremely dangerous to supply labels if you don't know what the breaks will be.

Examples

cbreaks(c(0, 100))
cbreaks(c(0, 100), breaks_pretty(3))
cbreaks(c(0, 100), breaks_pretty(10))
cbreaks(c(1, 100), log_breaks())
cbreaks(c(1, 1e4), log_breaks())

cbreaks(c(0, 100), labels = math_format())
cbreaks(c(0, 1), labels = percent_format())
cbreaks(c(0, 1e6), labels = comma_format())
cbreaks(c(0, 1e6), labels = dollar_format())
cbreaks(c(0, 30), labels = dollar_format())

# You can also specify them manually:
cbreaks(c(0, 100), breaks = c(15, 20, 80))
cbreaks(c(0, 100), breaks = c(15, 20, 80), labels = c(1.5, 2.0, 8.0))
cbreaks(c(0, 100),
  breaks = c(15, 20, 80),
  labels = expression(alpha, beta, gamma)
)

scales documentation built on July 4, 2024, 1:11 a.m.