【发布时间】:2016-10-03 20:17:38
【问题描述】:
我正在绘制 15 个散点图,其中包括回归线。但是,我想在一页上显示以更好地可视化。 grid.arrange 函数有助于根据我们的兴趣添加多个图但是我总是遇到错误。
gList(list(wrapvp = list(x = 0.5, y = 0.5, width = 1, height = 1, : “gList”中只允许使用“grobs”
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)
或
do.call(grid.arrange, c(plots, ncol=3))
【问题讨论】:
-
我正在编辑删除错误的标签。
标签: r plot scatter-plot