0

私はggplot2を使用して、9つのファセットを含む図をプロットしています。各ファセットは2つの変数間の関係を表し、統計的に有意な結果を表示するファセットに星印を付けます。これにより、' 'が付いた9つのファセットのうち2つだけになります。ただし、9つのファセットすべてに注釈が表示されることになります。

どうすればこれを修正できますか?

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

これは最小限の例です。重要なのは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 に答える