Is there any way to annotate a ggplot with three lines one on top of the other, while keeping the text sizes the same across the three lines?
I am almost there but the text sizes are different in the third line, it looks like the bgroup is only using the first two lines and I cannot get this right...
I am adding the text using to "atop" applications from "?plotmath", which works fine but the text in the third line comes out in a different size compared to the other two lines...
library(ggplot2)
line1 = "xxx data1"
line2 = "yyy data2"
line3 = "zzz data3"
df=data.frame(x=rep(1:8, 3), y=c(0,1,3,4,5,6,7,8, 8,7,6,3,2,1,3,4, 0,2,4,5,6,7,8,9), variable=c("x", "x","x","x","x","x","x","x","y","y","y","y","y","y","y","y","z","z","z","z","z","z","z","z"))
p <- ggplot(df) + theme_bw() + geom_point(aes(x=x,y=y, color=variable)) + geom_line(aes(x=x,y=y, color=variable)) +
geom_text(x=max(df$x), y = max(df$y), label = paste('bgroup("{", atop(atop("',line1,'","',line2,'"),"', line3,'"), "}")',sep=''), size=3.5,parse=TRUE)
I thought I was getting all the three lines within the bgroup, but I cannot get the paste right. If there is anything I can try please advise. Thanks very much!