【问题标题】:Colour individual lines in beanplot为 beanplot 中的单行着色
【发布时间】:2023-04-07 00:00:01
【问题描述】:

我想更改 beanplot 中各行的颜色。使用 col,我可以更改 bean 区域的颜色、bean 内部的所有线条、bean 外部的所有线条以及每个 bean 的平均线条。我想根据变量为不同的行分配不同的颜色。

x <- rnorm(15)
beanplot(x,ll = 1, col = c(0,1,1,2),
                 side = "both", axes = FALSE,method = "stack")

我想根据向量 colpref 分配颜色

colpref <- c(5, 5, 3, 5, 5, 3, 5, 5, 3, 3, 5, 5, 5, 3, 3)

【问题讨论】:

标签: r colors


【解决方案1】:

你可能可以像这样使用参数addwhat

beanplot(x[colpref==3],ll = 1, col = c(0,3,3,3), what=c(1,0,1,1),
         side = "both", axes = FALSE,method = "stack", add=FALSE)
beanplot(x[colpref==5],ll = 1, col = c(0,5,5,5), what=c(1,0,1,1),
         side = "both", axes = FALSE,method = "stack", add=TRUE)
beanplot(x,ll = 1, col = c(0,5,5,5), what=c(0,1,0,0),
         side = "both", axes = FALSE,method = "stack", add=TRUE)

【讨论】:

  • 啊,我认为 op 的意思是为 what == 4 中的所有线段单独分配颜色。我正忙着破解源代码。这更有意义
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-28
  • 2012-06-23
  • 1970-01-01
  • 2010-10-27
  • 1970-01-01
相关资源
最近更新 更多