I used vjust
as workaround and elaborate an
acceptable distance by try and error. But this is sometimes very time consuming and changes
with the font size and the axis scale.
Is there a better method to align the text in the example automatic?
library(ggplot2)
ggplot(data=mtcars, aes(x=hp, y=mpg))+
geom_point()+
theme_bw() +
geom_vline(xintercept=200, colour="grey") +
geom_text(aes(x=200, label="the strong cars", y=20), colour="blue", angle=90, vjust = 1.2, text=element_text(size=11))+
geom_text(aes(x=200, label="the weak cars", y=20), colour="red", angle=90, vjust = -1, text=element_text(size=11))
ggsave(filename="geomline.png", width=5.5, height=2*3, dpi=300)