我正在创建一个包含 3 个部分的图形,这些部分是使用metafor
包创建的森林图。如何减少子图之间的空白,使它们更靠近?
这是示例数据和代码
library(metafor)
dat <- read.csv(("https://raw.githubusercontent.com/aelhak/data/main/dat2.csv"))
graphics.off()
grDevices::cairo_pdf("plot.pdf", width = 4.5, height = 6)
layout(mat = matrix(c(1, 2, 3), nrow = 3, ncol = 1))
# SUB-PLOT 1
forest(
x = dat$estimate,
ci.lb = dat$conf.low,
ci.ub = dat$conf.high,
slab = dat$age_group,
xlab = "mean difference",
cex = 1, cex.lab = 0.7, psize = 1,
xlim = c(-16.7, 11),
alim = c(-3, 4.5),
# ylim = c(0, 71),
ilab = cbind(
dat$I2,
dat$n_studies,
dat$n_g1,
dat$n_g2),
ilab.xpos = c(-10.1, -8.2, -6.1, -3.85),
header = "Age\nGroup"
)
text(-10.65, 6, "I\xB2", font = 2, pos = 4)
text(-8.8, 6, "N\nSt.", font = 2, pos = 4)
text(-7.05, 6, "N\ng1", font = 2, pos = 4)
text(-4.9, 6, "N\ng2", font = 2, pos = 4)
title("sub-plot 1", adj = 0)
# SUB-PLOT 2
forest(
x = dat$estimate,
ci.lb = dat$conf.low,
ci.ub = dat$conf.high,
slab = dat$age_group,
xlab = "mean difference",
cex = 1, cex.lab = 0.7, psize = 1,
xlim = c(-16.7, 11),
alim = c(-3, 4.5),
# ylim = c(0, 71),
ilab = cbind(
dat$I2,
dat$n_studies,
dat$n_g1,
dat$n_g2),
ilab.xpos = c(-10.1, -8.2, -6.1, -3.85),
header = "Age\nGroup"
)
text(-10.65, 6, "I\xB2", font = 2, pos = 4)
text(-8.8, 6, "N\nSt.", font = 2, pos = 4)
text(-7.05, 6, "N\ng1", font = 2, pos = 4)
text(-4.9, 6, "N\ng2", font = 2, pos = 4)
title("sub-plot 2", adj = 0)
# SUB-PLOT 3
forest(
x = dat$estimate,
ci.lb = dat$conf.low,
ci.ub = dat$conf.high,
slab = dat$age_group,
xlab = "mean difference",
cex = 1, cex.lab = 0.7, psize = 1,
xlim = c(-16.7, 11),
alim = c(-3, 4.5),
# ylim = c(0, 71),
ilab = cbind(
dat$I2,
dat$n_studies,
dat$n_g1,
dat$n_g2),
ilab.xpos = c(-10.1, -8.2, -6.1, -3.85),
header = "Age\nGroup"
)
text(-10.65, 6, "I\xB2", font = 2, pos = 4)
text(-8.8, 6, "N\nSt.", font = 2, pos = 4)
text(-7.05, 6, "N\ng1", font = 2, pos = 4)
text(-4.9, 6, "N\ng2", font = 2, pos = 4)
title("sub-plot 3", adj = 0)
dev.off()