我想在多重图的每个绘图窗口周围画一个彩色边框。请考虑以下示例:
par(mfrow = c(2, 2)) plot(1, 1) plot(1, 1) plot(1, 1) plot(1, 1)
输出:
但是,多倍增应该如下所示:
我怎么能在R里那样做?
一种方法是简单地使用 box() 在每一个情节之后起作用。为了得到不同的线条粗细,我使用了两个参数: "outer" 和 "figure" 指定框的绘制位置。
box()
"outer"
"figure"
所以代码看起来是这样的
par(mfrow = c(2, 2)) plot(1, 1) box("outer", col="green4", lwd = 30) # lwd - line tickness/width plot(1, 1) box("figure", col="green4", lwd = 5) plot(1, 1) box("figure", col="green4", lwd = 5) plot(1, 1) box("outer", col="green4", lwd = 30)
以及输出: