编译的图形面板的通用主标题

编译的图形面板的通用主标题

本文介绍了使用 par(mfrow) 编译的图形面板的通用主标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由 par(mfrow=c(2,2)) 绘制的 4 个图的汇编.我想为上面的 2 个图绘制一个通用标题,并为位于 2 个左右图之间的中心的下面 2 个面板绘制一个通用标题.

I have a compilation of 4 plots drawn together with par(mfrow=c(2,2)). I would like to draw a common title for the 2 above plots and a common title for the 2 below panels that are centered between the 2 left and right plots.

这可能吗?

推荐答案

应该有效,但你需要使用 line 参数来获得它恰到好处:

This should work, but you'll need to play around with the line argument to get it just right:

par(mfrow = c(2, 2))
plot(iris$Petal.Length, iris$Petal.Width)
plot(iris$Sepal.Length, iris$Petal.Width)
plot(iris$Sepal.Width, iris$Petal.Width)
plot(iris$Sepal.Length, iris$Petal.Width)
mtext("My 'Title' in a strange place", side = 3, line = -21, outer = TRUE)

mtext 代表边距文本".side = 3 表示将其放在顶部"边距中.line = -21 表示将放置偏移 21 行.outer = TRUE 表示可以使用外边距区域.

mtext stands for "margin text". side = 3 says to place it in the "top" margin. line = -21 says to offset the placement by 21 lines. outer = TRUE says it's OK to use the outer-margin area.

要在顶部添加另一个标题",您可以使用,例如,mtext("My 'Title' in a unique place", side = 3, line = -2, outer = TRUE)

To add another "title" at the top, you can add it using, say, mtext("My 'Title' in a strange place", side = 3, line = -2, outer = TRUE)

这篇关于使用 par(mfrow) 编译的图形面板的通用主标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 18:00