0

我正在使用 ggplot2 绘制一个包含九个方面的图形。每个方面代表两个变量之间的关系,我想用星号' '注释显示统计显着结果的方面。这将导致九个刻面中只有两个带有“ ”。然而,我最终得到了显示注释的所有九个方面。

我怎样才能解决这个问题?

library(ggplot2)

Sig<-c("","*","","","","","","*","") # Only the second and the second to last facets should receive significance stars.
Data.annot<-data.frame(unique(Aspects),Sig)

qplot(Labels,Es,data=Data1) + geom_pointrange(aes(x=Labels,y=Es,ymin=Low,ymax=Up)) + geom_hline(yintercept=0, linetype="dashed") + coord_flip() + facet_wrap(~Aspects, scales="free") + geom_text(data=Data.annot, aes(x= 0.5, y= 1, label = Sig)) + scale_y_continuous("Correlation coefficient\n(effect size)",limits=c(-0.5,1),breaks=c(-0.5,0,0.5,1.0)) + scale_x_discrete("")
4

1 回答 1

2

This would be a minimum example. What is important is the data for geom_text.

dat<-data.frame(fa=gl(4,3),x=runif(12),y=runif(12))
q<-ggplot(dat,aes(x=x,y=y))+geom_point()+facet_wrap(~fa)+
geom_text(data=data.frame(fa=gl(4,1),sig=c("","*","","+")),aes(x=0.5,y=0.5,label=sig))
print(q)

HTH.

于 2010-04-14T09:15:38.650 回答