ggplot2 - R ggplot annotated with atop using three values and bgoup -
is there way annotate ggplot 3 lines 1 on top of other, while keeping text sizes same across 3 lines?
i there text sizes different in third line, looks bgroup using first 2 lines , cannot right...
i adding text using "atop" applications "?plotmath", works fine text in third line comes out in different size compared other 2 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 getting 3 lines within bgroup, cannot paste right. if there can try please advise. much!
Comments
Post a Comment