What line of code can I add to this plot so that the x-axis labels appear just below height y=0 if the bars are positive, and just above y=0 if the bars are negative?
I have another plot that I need to produce that will only have 4 bars (different x-axis labels) and I'd like the code to work for that one as well, i.e. not specific to the labels in this plot, so that I can facet them.
I'm thinking it would be great if there was something like if y >0 then x-axis label at y=-1 else x-axis label at y=1...


Just add a new
yvalue for the text that is based on the sign of the realyvalue of the bar.The use of
2*is up to your real values, feel free to play with that.As an alternative, in case you want the on-top/below values to be asymmetric, you can replace
2*sign(y)withifelse(y < 0, 3, -2).