This function provides a convenient way to set default options for breaks
arguments in openair plots, which cut continuous colour scales into
discrete bins.
Usage
breakOpts(
breaks = NULL,
labels = NULL,
method = c("number", "interval", "width", "pretty", "wd"),
max.bins = NULL,
include.lowest = NULL,
right = NULL,
dig.lab = NULL
)Arguments
- breaks, labels
If a categorical colour scale is required,
breaksshould be specified. This can be either of:A single value, which will use the strategy specified by
methodto bin the scale. By default, this uses the same logic ascutData(), which splits the scale into quantiles.A numeric vector, which will define the specific breakpoints. For example,
c(0, 50, 100)will bin the data into0 to 50,50 to 100, and so on. Ifbreaksdoes not cover the full range of the data, the outer limits will be extended so that the full colour scale is covered while retaining the desired number of breaks.
By default,
breakswill generate nicely formatted labels for each category. Thelabelsargument overrides this - for example, a user could definebreaks = 3, labels = c("low", "medium", "high"). Care should be taken to provide the appropriate number oflabels- it should always be equal to the number of bins, or one less than the number of breakpoints.- method
When
breaksis a single number (e.g.,breaks = 5),methodcontrols how this value is used to create breaks. Can be one of:"number"- splits the range into n quantiles (i.e., bins with roughly the same number of measurements in them). This is equivalent tocutData()."interval"- splits the range into n bins of equal width."width"- splits the range into some number of bins with width n."pretty"- splits the range into approximately n bins with aesthetically pleasing breakpoints usingpretty()."wd"- splits the range into wind direction bins by passing it tocutData(). Note that this option requiresbreaksto be one of4,8,16or32and ignores all other arguments.
- max.bins
If
max.binsis set, only that number of bins will ever be created. For example, ifbreaks = c(0, 10, 20, 30, 40, 50)andmax.bins = 3,breakswill be set toc(0, 10, 20, 50)to ensure only three bins are made.- include.lowest
logical, indicating if an
x[i]equal to the lowest (or highest, forright = FALSE) 'breaks' value should be included.- right
logical, indicating if the intervals should be closed on the right (and open on the left) or vice versa.
- dig.lab
Integer which is used when labels are not given. It determines the number of digits used in formatting the break numbers. If
NULL, the labels will use the minimum number of decimal places possible to ensure the breakpoints are unique, dropping all trailing zeroes.
