【发布时间】:2013-03-02 02:58:52
【问题描述】:
我正在使用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
^
【问题讨论】: