ggplot2-用上标注释文本 [英] ggplot2 - annotate text with superscript

查看:254
本文介绍了ggplot2-用上标注释文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在绘图中添加一个R ^ 2值.我将标签传递给geom_text()如下;

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"))))

但它绘制为=(R ^ 2,0.43).有什么想法吗?

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

推荐答案

您希望标题为"R ^ 2 == 0.43".查看plotmath的帮助页面.在那里显示==给您平等.

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

要回答问题后的评论,可以在表达式中使用atop. "atop(R^2==0.43,p==0.763)"这适用于两行,但不能更多.

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.

这篇关于ggplot2-用上标注释文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆