我用来在我的一个情节annotate()
上覆盖文本。ggplot2
我使用该选项parse=T
是因为我需要使用希腊字母 rho。我希望文字说= -0.50
,但尾随的零被剪掉了,而我得到-0.5
了。
这是一个例子:
library(ggplot2)
x<-rnorm(50)
y<-rnorm(50)
df<-data.frame(x,y)
ggplot(data=df,aes(x=x,y=y))+
geom_point()+
annotate(geom="text",x=1,y=1,label="rho==-0.50",parse=T)
有谁知道我怎样才能让最后一个 0 出现?我以为我可以这样使用paste()
:
annotate(geom="text",x=1,y=1,label=paste("rho==-0.5","0",sep=""),parse=T)
但后来我得到了错误:
Error in parse(text = lab) : <text>:1:11: unexpected numeric constant
1: rho==-0.5 0
^