绘制 3 列栅格并使用 base R 保存为 pdf

Plotting 3 columns of rasters and saving into pdf with base R

抱歉,这个例子不能完全重现(我没有提供准确的输入数据),但希望这个例子会很清楚。

简而言之,我想将三张地图保存为宽 pdf 格式,这样所有三张地图都可以以所需的范围显示 + 上面有一个总体标题(但我不希望它占用页面的一半)。

我真的很难正确设置它:

pdf("plots1.pdf",width = 30/2.54,height = 20/2.54)
par(mfrow = c(2,3))
layout(matrix(c(1,1,1,2,3,4), 2, 3, byrow = TRUE))
plot.new()
text(0.5,0.5,"Africa, Params_1",cex=2,font=2)
# plot.new()
# plot.new()
plot(r2_list[[1]], xlim = Region[[g]][1:2], ylim = Region[[g]][3:4],
     breaks=cuts, col = plasma(21), main = variable[1],legend=FALSE)
plot(wrld_simpl,add=TRUE)
plot(r2_list[[2]], xlim = Region[[g]][1:2], ylim = Region[[g]][3:4],
     breaks=cuts, col = plasma(21), main = variable[2],legend=FALSE)
lines(wrld_simpl)
plot(r2_list[[3]], xlim = Region[[g]][1:2], ylim = Region[[g]][3:4],
     breaks=cuts, col = plasma(21), main = variable[3])
lines(wrld_simpl)

dev.off()

我还想再次尝试打印 6 个图 - 带有总体标题,但我惨遭失败。 非常感谢您的帮助。

heights= 添加到您的 layout 通话中。

layout(matrix(c(1,1,1, 2,3,4), byrow=TRUE, nr=2), heights = c(1, 8))
opar <- par(mar=c(0,0,0,0))
plot.new()
text(0.5,0.5,"Africa, Params_1",cex=2,font=2)
par(opar)
plot(1:20)
plot(3:99)
plot(1:2)

(下图蓝色边界外加,仅供参考。)

没有heights

如果我从上面的代码中删除 heights=,我会看到:

heights

(您需要根据您的 canvas 尺寸等使用实际值)