ggplot2 - annotate text with superscript

浪子不回头ぞ 提交于 2019-12-10 15:18:30

问题


I want to add an R^2 value to my plot. I passed the label to geom_text() as follows;

 geom_text(aes(x,y,label=caption),parse=T,
        data.frame(x=-2,y=80,caption=("R^2=0.43"))))

but it plots as =(R^2,0.43). Any ideas?


回答1:


You want your caption to be "R^2==0.43". Look at the help page for plotmath. There it shows that == gives you equals.

EDIT:

To answer the comment after the question, you can use atop in the expression. "atop(R^2==0.43,p==0.763)" This works for two lines, but not more.



来源:https://stackoverflow.com/questions/7182247/ggplot2-annotate-text-with-superscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!