【发布时间】:2018-06-30 08:11:59
【问题描述】:
我想在多图的每个绘图窗口周围绘制一个彩色边框。考虑以下示例:
par(mfrow = c(2, 2))
plot(1, 1)
plot(1, 1)
plot(1, 1)
plot(1, 1)
输出:
但是,多图应该如下所示:
我怎么能在 R 中做到这一点?
【问题讨论】:
标签: r plot background-color
我想在多图的每个绘图窗口周围绘制一个彩色边框。考虑以下示例:
par(mfrow = c(2, 2))
plot(1, 1)
plot(1, 1)
plot(1, 1)
plot(1, 1)
输出:
但是,多图应该如下所示:
我怎么能在 R 中做到这一点?
【问题讨论】:
标签: r plot background-color
一种方法是在每次绘图后简单地使用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)
然后输出:
【讨论】: