-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shortcut for scale_y_continuous(expand = expansion(c(0, 0.05))
#3962
Comments
I think this is a good idea, but I'd propose a different interface. We already have Not sure how to implement this though. I'll have to look into how |
I like the idea of In any case, I'd be more than happy to implement something along these lines and make a pull request 😀 |
I've thought about this a bit and at this time I'm not sure how to implement this. |
Seems like neither I guess if you make all aspects of all scales modifiable you have |
We now have the following, which is at least easier to understand: we turn off the expansion at the bottom of the plot. devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2
ggplot(mtcars, aes(hp)) +
geom_histogram() +
coord_cartesian(expand = c(bottom = FALSE))
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`. Created on 2025-01-07 with reprex v2.1.1 |
When creating histogram or bar charts the standard expansion factor of
0.05
creates an unsighty gap between the bars and the x axis.To remove this gap currently one has to add
scale_y_continuous(expand = expansion(c(0, 0.05))
to the plot. This is cumbersome to type, easy to forget and hard to grasp for beginners.I'd love to have a shortcut for that, something like:
This is in the same spirit as
ylab()
orylim()
.Thinking a bit further maybe this could even be an option:
This would force the axis limits to be exactly those requested which is not the case currently with
ylim()
.The text was updated successfully, but these errors were encountered: