R/break_setter.R

Defines functions break_setter

Documented in break_setter

#' Returns an appropriate function to pass to the \code{breaks}
#' argument of any \code{continuous_scale}
#'
#' @param n suggested number of breaks (defaults to 5)
#'
#' @examples
#' \dontrun{
#' ggplot(mtcars, aes(x = disp, y = mpg)) +
#' geom_point() +
#'     scale_y_log10()
#'
#'  ggplot(mtcars, aes(x = disp, y = mpg)) +
#'      geom_point() +
#'          scale_y_log10(breaks = break_setter())
#'
#'  ggplot(mtcars, aes(x = disp, y = mpg)) +
#'      geom_point() +
#'      scale_y_log10(breaks = break_setter(10))
#' }
#' @export
break_setter <- function(n = 5) {
    function(lims) {pretty(x = as.numeric(lims), n = n)}
}
gregorp/gregor documentation built on May 17, 2019, 8:36 a.m.