【问题标题】:Adding multiple plots at one page grid.arrange function在一页 grid.arrange 函数中添加多个图
【发布时间】: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


【解决方案1】:

grid.arrange 需要基于网格的图形。 base plot() 不返回任何内容。您可能应该查看split.screenlayoutpar(mfrow=...)。或者(作为最后的手段)查看 gridBase 或 gridGraphics 包以了解组合这两个系统的方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-17
    • 2020-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多