我在多个页面上有多个图表,如何为所有页面提供相同的mtext?下面是一个示例数据集:
bootData <- lapply(seq(1,24), function(x) rnorm(50))
names(bootData) <- c("0", "2", "4", "6", "8", "10", "15", "20", "30", "40", "45",
"50", "55", "60", "65", "70", "80", "85", "90", "92", "94", "96",
"98", "100")
绘制数据
pdf(file = "test.pdf", width = 11.5, height = 8.5)
par(mar=c(5,4,3,2), oma=c(3,3,1,3), mfrow = c(2,3))
lapply(names(bootData), function(x) hist(bootData[[x]], main = paste("Histogram of", x)))
mtext("Error per label", side = 1, line = 1, outer = TRUE, col = "firebrick")
dev.off()
我希望mtext&#34;每个标签错误&#34;出现在每个页面中。使用上面的代码,它只出现在最后一页。
非常感谢提前。
答案 0 :(得分:2)
pdf(file = "test.pdf", width = 11.5, height = 8.5)
par(mar=c(5,4,3,2), oma=c(3,3,1,3), mfrow = c(2,3))
lapply(names(bootData), function(x){
hist(bootData[[x]], main = paste("Histogram of", x))
mtext("Error per label", side = 1, line = 1, outer = TRUE, col = "firebrick")
})
dev.off()