【问题标题】:Colored border around multiple plots多个地块周围的彩色边框
【发布时间】: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


    【解决方案1】:

    一种方法是在每次绘图后简单地使用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) 
    

    然后输出:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-12
      • 1970-01-01
      • 2023-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-22
      相关资源
      最近更新 更多