如何在plot(ggplot2)的文本注释中放置+/- plus减号运算符? [英] How to place +/- plus minus operator in text annotation of plot (ggplot2)?
本文介绍了如何在plot(ggplot2)的文本注释中放置+/- plus减号运算符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了以下方法,但对我无效:
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 =表达式(%+ - %))$ b $注解(text,x = 0.5,y = 0.3,label =myplot b
我也尝试了如何用乳胶注释()ggplot 没有运气:
a < - a +注释(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表示(
\\\±
): p>
a< - ggplot()
a < - a + g eom_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 =\\\±)
或者您可以直接使用
±
符号,从某处复制并粘贴它。a + annotate(text,x = 0.5,y = 0.2,label =±)
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(%+-%))
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)
And this doesn't work either:
a <- a + annotate("text", x=0.5, y=0.1, label="\pm", parse=TRUE)
解决方案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="±")
这篇关于如何在plot(ggplot2)的文本注释中放置+/- plus减号运算符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文