Set origin to zero
Opened this issue · 1 comments
AliciaSchep commented
Especially for bar charts, I often want to set the bottom of a plot to zero. This is now fairly easy thanks to tidyverse/ggplot2#1805
ggplot(mtcars) +
geom_bar(aes(x = factor(cyl))) +
scale_y_continuous(expand = c(0, 0, 0.1, 0))
For a chart where data doesn't automatically go to zero, you also need something like limits = c(0,NA)
I'm not exactly sure yet what the best form of a helper here is, will think and update, but wanted to get the ball rolling with issues for possible helpers.
AliciaSchep commented
Thinking about this a bit more, I think what might be helpful is something like easy_exact_ylim
which is like ylim
but also sets expand
to 0 for any non-NA bound, so that the limits you set are exactly the limits of the plots.