它更容易幫助具體的例子,但模擬了一些數據,也許這將幫助:
![enter image description here](https://i.stack.imgur.com/cFomj.png)
#simulate data
completeFrame<-data.frame(P_Value=rnorm(200,0.8,0.1),Generation=rep(1:4,times=50))
#draw the basic plot
h3 <- qplot(data=completeFrame,x=P_Value,geom="blank") +
geom_bar(binwidth=0.02, col="black", fill="black") +
# overlay the "red" bars for the subset of data
geom_bar(data=completeFrame[which(completeFrame$P_Value>0.8),],binwidth=0.02, col="black", fill="red") +
facet_wrap(~ Generation)
#add lines to the subsets
h3 <- h3+geom_hline(data=completeFrame[which(completeFrame$Generation==2),],aes(yintercept=max(P_Value)))
h3 <- h3+geom_hline(data=completeFrame[which(completeFrame$Generation==1),],aes(yintercept=2.5))
h3 <- h3+geom_hline(data=completeFrame[which(completeFrame$Generation==3),],aes(yintercept=mean(P_Value)))
h3
人一般更樂意幫助,如果你提供一個[_minimal_,重複的例子, ](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610)並顯示你已經嘗試過的代碼。謝謝! – Henrik