I have created a for
looped code using ggplot2
to create similar bar plots using a large analysed dataset. I have added code to make the origin be at y=0, without the gap that seems to be standard with ggplot2
with:
scale_y_continuous(expand = c(0,0))
Which means that the graphs are now automatically cutting off at to top of the largest error bar (see picture below).
I know that I can hard code in the limits of the graph as so:
scale_y_continuous(expand = c(0,0), limits = c(0, 100), breaks = seq(0,100,25))
But I am using a loop and not all graphs will need the same limits. Does anyone know a way to set the y limits to say 10 units above the height that the error bar reaches?
I have tried using (sem is what the error bars are measured by):
scale_y_continuous(expand = c(0,0), limits = c("Mean" + "sem"))
But that doesn't work as they are non-numeric
Error in "Mean" + "sem" : non-numeric argument to binary operator
Recommendations greatly appreciated! Sorry I haven't included reproducible data, but this problem is not specific to my data!