get_breaks: Create nice axis breaks for plots

Description Usage Arguments Details Value Examples

View source: R/plot-utils.R

Description

Set the breaks for a graph in nice positions.

Usage

1
2
3
4
get_breaks(limits, N = 10, max_breaks = 10, int_only = TRUE,
  multiples_only = FALSE, include_bounds = TRUE)

ggplot_breaks(...)

Arguments

limits

axis limits. May be either a vector of 2 elements with lower and upper bounds, or a single number (which is the upper bound, the lower bound is then assumed to be 0).

N

step size. The eventual intervals will be multiples of the divisors of N or multiples of N when multiples_only is TRUE. Defaults to 10.

max_breaks

maximum amount of breaks, defaults to 10.

int_only

whether only integer divisors of N may be used as breaks, defaults to TRUE.

multiples_only

whether only multiples of N can be used as breaks, defaults to FALSE.

include_bounds

whether the resulting breaks should encompass min and max. Defaults to TRUE.

...

Arguments passed on to get_breaks

limits

axis limits. May be either a vector of 2 elements with lower and upper bounds, or a single number (which is the upper bound, the lower bound is then assumed to be 0).

N

step size. The eventual intervals will be multiples of the divisors of N or multiples of N when multiples_only is TRUE. Defaults to 10.

max_breaks

maximum amount of breaks, defaults to 10.

int_only

whether only integer divisors of N may be used as breaks, defaults to TRUE.

multiples_only

whether only multiples of N can be used as breaks, defaults to FALSE.

include_bounds

whether the resulting breaks should encompass min and max. Defaults to TRUE.

Details

get_breaks is the base function and creates a vector of breaks ggplot_breaks is a wrapper and makes usage easier in ggplot2. The limits of the axis may not be known beforehand, but ggplot_breaks receives it from ggplot and then creates nice breaks.

Value

A sorted numerical vector with breaks of length |max_breaks|+2 when include_bounds is TRUE and of size |max_breaks| otherwise.

Examples

1
2
3
4
5
get_breaks(24, N=12, max_breaks=15)

## Not run: 
ggplot() + scale_x_continuous(breaks = ggplot_breaks(N=12, max_breaks=15))
## End(Not run)

hgvandenboorn/hgutils documentation built on Sept. 9, 2019, 2:50 a.m.