r - 使用 spplot 在 R 中的单个页面上放置多个图?

标签 r plot

我知道如何在使用简单函数 plot 时绘制两个图:

 old.par <- par(mfrow=c(1, 2))
 plot(faithful, main="Faithful eruptions")
 plot(large.islands, main="Islands", ylab="Area")
 par(old.par)

这将返回诸如:

enter image description here

我需要为相当复杂的 spplot 函数做同样的事情。我想要的是一个 3 x 3 的正方形。

我想绘制 9 次的函数是:
labelat = fivenum(gwr.res$SDF$Unempl)
labeltext = labelat 


spplot(gwr.res$SDF, "Unempl", cuts = 4, at = c(fivenum(gwr.res$SDF$Unempl)),     col.regions = Greens,
    colorkey=list(width=0.3,      
              space="right", 
              tick.number=5, 
              labels=list(  
                at=labelat, 
                labels=labeltext ))) 

关于如何解决这个问题的任何想法?

谢谢,

最佳答案

使用 grid.arrange 包中的 gridExtra 。执行 grid.arrange(spplot(..),spplot(...),spplot(.....)) 等会将它们排列在网格中。

这是一个使用 meuse 数据集的示例,该数据集生成 9 个这样的图,然后使用 do.call 来节省必须执行的 grid.arrange(plots[[1], plots[[2]], 等等,最多 9 个:

> require(gridExtra)
> plots = lapply(names(meuse)[1:9], function(.x) spplot(meuse,.x))
> do.call(grid.arrange,plots)

3x3 grid

关于r - 使用 spplot 在 R 中的单个页面上放置多个图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32378151/

相关文章:

r - 从Survreg解释Weibull参数

python - 线性回归 - 使用 MinMaxScaler() 获取特征重要性 - 极大的系数

r - 拆分上方和下方部分的图以进行 3 阶乘条形图

python - 尝试绘制简单的条形图时出错

python-2.7 - 为什么 Python 线图显示 : Don't have an account? plot.ly

r - R 中作为数据框的分类变量频率表

r - 如何对使用 R 包 CausalImpact 中实现的贝叶斯结构时间序列模型进行的预测施加限制?

r - 在单个图中获取 geom_hex 中的观测值( Shiny )

r - 绘图选项 'bg' 不工作

R将corrplot返回为对象