7
我正在使用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
^
工作。谢谢! – 2013-03-14 15:03:18