如何在绘图(ggplot2)的文本注释中放置 +/- 加减运算符? [英] How to place +/- plus minus operator in text annotation of plot (ggplot2)?

查看:11
本文介绍了如何在绘图(ggplot2)的文本注释中放置 +/- 加减运算符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了以下方法,但对我不起作用:

I have tried the following, but it doesn't work for me:

a <- ggplot()
a <- a + geom_point(aes(x=seq(0,1,0.1), y=seq(0,1,0.1)))
a <- a + annotate("text", x=0.5, y=0.3, label="myplot")
a <- a + annotate("text", x=0.5,y=0.2,label=expression(%+-%))

我还尝试了 How to annotate() ggplot with乳胶没有运气:

I have also tried the following as pointed out by How to annotate() ggplot with latex with no luck:

a <- a + annotate("text", x=0.5, y=0.1, label="%+-%", parse=TRUE)

这也不起作用:

a <- a + annotate("text", x=0.5, y=0.1, label="pm", parse=TRUE)

推荐答案

可以使用unicode表示(u00B1):

It is possible to use the unicode representation (u00B1):

a <- ggplot()
a <- a + geom_point(aes(x=seq(0,1,0.1), y=seq(0,1,0.1)))
a <- a + annotate("text", x=0.5, y=0.3, label="myplot")
a + annotate("text", x=0.5, y=0.2, label="u00B1")

或者您可以直接使用 ± 符号,方法是从某处复制和粘贴它.

Or you can use the ± symbol directly, by copying and pasting it from somewhere.

a + annotate("text", x=0.5, y=0.2, label="±")

这篇关于如何在绘图(ggplot2)的文本注释中放置 +/- 加减运算符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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