我在向我的绘图添加注释时使用plotmath支持,即使用parse=TRUE参数。回顾这里的绘图文档,不清楚如何转义预定义的符号,例如%
label <- 'atop(This~goes~on~top,of~this~with~11.1%)' # how to escape the % sign?
geom_text(...,label=label,parse=TRUE)这将导致以下错误:
Error in parse(text = as.character(lab)) : <text>:1:40: unexpected input
1: atop(This~goes~on~top,of~this~with~11.1%)
^发布于 2017-09-07 16:43:12
把它写在引号里
label <- 'atop(This~goes~on~top,of~this~with~"11.1%")'
ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() +
annotate("text", x = 4, y = 25, label = label, parse=TRUE)只要把所有的测试都写进引号
label <- 'atop("This goes on top of this with 11.1%")'https://stackoverflow.com/questions/46101350
复制相似问题