How to adjust y-axis ranges dynamically is ggplot2?
ggplot2, r
Solution
How about using `+ scale_y_continuous(expand=c(0.15,0))` after your existing code:
`expand=` expects a 2-number vector of multiplicative and additive scale factors
Problem
How can I adjust y-axis so that the annotations are also shown properly in this kind of plot? ``` library(ggplot2) ggplot(diamonds, aes(x = cut, y = depth)) + facet_wrap(~ color) + stat_summary(fun.y = sum, geom="bar", fill = "yellow", aes(label=cut, vjust = 0)) + stat_summary(fun.y = sum, geom="text", aes(label=cut), vjust = 0) ``` Now for example in facet G annotation for 'Ideal' is not shown properly. Y-axis range should be calculated dynamically, so that there is always some space for annotation above bars. So I can not use fixed y-axis ranges.