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