为beanplot中的各个行着色 [英] Colour individual lines in beanplot
本文介绍了为beanplot中的各个行着色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想更改beanplot中各行的颜色。使用col,我可以更改bean区域的颜色,bean内部的所有行,bean外部的所有行以及每个bean的平均行。我想根据变量将不同的颜色分配给不同的行。
I would like to change the colors of the individual lines in a beanplot. Using col, I can change the color of the bean area, all lines inside the bean, all lines outside the bean, and average line per bean. I would like to assign different colors to different lines depending on a variable.
x <- rnorm(15)
beanplot(x,ll = 1, col = c(0,1,1,2),
side = "both", axes = FALSE,method = "stack")
我想基于矢量colpref
I would like to assign colors based on the vector colpref
colpref <- c(5, 5, 3, 5, 5, 3, 5, 5, 3, 3, 5, 5, 5, 3, 3)
推荐答案
您可能可以使用参数 add
和 what
像这样
you can probably play with the parameter add
and what
like this
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)
这篇关于为beanplot中的各个行着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文