gg_integer_breaks: Apply integer breaks to a graph.

View source: R/zulugg.R

gg_integer_breaksR Documentation

Apply integer breaks to a graph.

Description

Calculates a vector of breaks that contains all integers between 0 and max(x) (with a little bit of extra headroom in case the maximum element is an integer)

Usage

gg_integer_breaks(x)

Arguments

x

The input vector for which the breaks should be calculated. Note that there is no fancy NSE here, the actual variable must be passed to the function, and also that the function currently does not handle negative data and will error out if passed such data.

Value

A vector of breaks suitable for use with ggplot breaks parameter.

See Also

Other functions extending ggplot: gg_apply_labs(), gg_apply()

Examples

if ( require(ggplot2) ) {
  ggplot(mtcars) +
    aes(wt,drat) +
    geom_point() +
    scale_y_continuous(breaks=gg_integer_breaks(mtcars$drat))
}


torfason/zulutils documentation built on Aug. 21, 2023, 5:46 p.m.