且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在绘图(ggplot2)的文本注释中放置 +/- 加减运算符?

更新时间:2023-11-26 13:27:34

可以使用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="±")