开发者

ggplot2 - annotate text with superscript

开发者 https://www.devze.com 2023-03-30 18:49 出处:网络
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,

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号