equal_breaks: Helper function for 'ggplot"s 'scale_x/y_continuous'

View source: R/equal_breaks.R

equal_breaksR Documentation

Helper function for ggplot's scale_x/y_continuous

Description

Allows faceted free_x and free_y scales to have equal number of breaks with differing ranges

Usage

equal_breaks(n = 3, s = 0.05, ...)

Arguments

n

number of breaks

sf

scaling factor (multiplicative expand) - higher sf will result in wider margins before ticks begin

Examples

library(ggplot2)
ggplot(data = iris, aes(x = Petal.Width, y = Sepal.Length)) +
  geom_point() +
  facet_grid( ~ Species, scales = "free") +
  scale_x_continuous(breaks=equal_breaks(n=3, sf=.05),
                     expand = c(0.05, 0))

olsonma/mollr documentation built on Aug. 2, 2022, 9:17 p.m.