【发布时间】:2014-12-04 20:05:00
【问题描述】:
无法在 ggplot annotate 中添加希腊字母,如果:它夹在其他文本之间,或者相关文本包含撇号。
例如,以下工作正常:
df <- data.frame(x = rnorm(10), y = rnorm(10))
temp<-paste("rho == 0.34")
ggplot(df, aes(x = x, y = y)) + geom_point() +
annotate("text", x = mean(df$x), y = mean(df$y), parse=T,label = temp)
但是,当我这样做时,ggplot 会爆炸:
df <- data.frame(x = rnorm(10), y = rnorm(10))
temp<-paste("Spearman's rho == 0.34")
ggplot(df, aes(x = x, y = y)) + geom_point() +
annotate("text", x = mean(df$x), y = mean(df$y), parse=T,label = temp)
ggplot 对这些特殊字符非常敏感。其他帖子似乎没有解决这个问题(如果没有,请道歉)。提前致谢。
【问题讨论】:
-
plot(1,1,t="n");text(1,1,expression("Spearman's"~rho == 0.34))