2016-10-03 76 views
0

我繪製了15個包含迴歸線的散點圖。不過,我想在一個頁面上展示以更好地形象化。 grid.arrange函數有助於根據我們的興趣添加多個圖,但是我總是面對一個錯誤。在一個頁面上添加多個圖格.arrange函數

錯誤爲Glist(列表(wrapvp =列表(x = 0.5,Y = 0.5,寬度= 1,高度= 1,: 僅在 「爲Glist」 允許

plots <- list() 
for (i in 1:(ncol(xx2)-1)) { 

    cn <- colnames(xx2) 

    reg<-lm(xx2[,i]~xx2[,16], data=data.frame(xx2)) 
    aa<-summary(reg) 
    p1<-plot(xx2[,16], xx2[,i], xlab=cn[16], ylab=cn[i], 
     pch=1, cex.main=1.5, frame.plot=FALSE, col="grey")+ abline(reg, col="blue", lwd=2) + text(max(xx2[,16]/1.3), max(xx2[,i])/2, paste("R-Squared:",round(aa$r.squared,3)),cex = .8) 
    #plot(density(resid(reg))) 
    plots[[i]] <- p1 

} 
grid.arrange(grobs = plots[1:15], ncol=5) 

'grobs' OR

do.call(grid.arrange, c(plots, ncol=3)) 
+0

我在編輯刪除錯誤的標籤。 –

回答

0

grid.arrange需要基於網格的圖形。壘積()不返回任何東西。你或許應該看看split.screenlayoutpar(mfrow=...);或者(如最後再排序)查看gridBase或gridGraphics軟件包,瞭解組合這兩個系統的方法。

相關問題