Consolidate coordinate scale expansion and limiting code #3380
This is a PR to address coordinate scale expansion and limiting using a single approach, implementing several feature requests and fixing several bugs in the process (closes #2990, closes #2907, closes #3056, closes #3336). The inspiration for this PR was a collection of issues that @hadley collected when issue triaging that were related to the interface between scales and coordinate systems (#3371). I'd be happy to split this up into a few different PRs if it is easier to review (one for expansion, one for coord limiting, one for sprucing up coord_trans).
library(ggplot2) ggplot(mpg, aes(cty, hwy)) + geom_point() + coord_cartesian(xlim = c(20, NA), ylim = c(NA, 40))
library(ggplot2) p <- ggplot(mpg, aes(class, hwy)) + geom_boxplot() # these two plots didn't used to align and sometimes had # different breaks on the y-axis p + scale_y_log10() p + coord_trans(y = "log10") + scale_y_continuous(breaks = scales::log_breaks())