简体   繁体   English

蜂巢中央对齐的“逐点”颜色

[英]Centrally aligned “Point-wise” colors in beeswarm

Is it possible to draw a beeswarm plot such that point-wise colors are aligned in the horizontal center? 是否可以绘制蜂巢图以使点向颜色在水平中心对齐? (I believe this would improve the readability a lot especially if the data is not as clear-cut as in the example.) (我相信这将大大提高可读性,特别是如果数据不像示例中那样清晰明了。)

To achieve this plot with centered colors: 要使用居中颜色实现此绘图:

beeswarm(breast$time_survival, pch = 16, pwcol = 1 + breast$event_survival, method='center')

I tried: 我试过了:

beeswarm(breast$time_survival, pch = 16, method='center')
beeswarm(breast[breast$event_survival==1,]$time_survival, pch = 16, col=2, method='center', add=T)

It's close, but the individual points on the individual plots are not precisely the same. 距离很近,但是各个图上的各个点并不完全相同。

I think you were on the right track. 我认为您在正确的轨道上。 Here's one approach: 这是一种方法:

data(breast)

## Create a blank plot with appropriate limits and axes
beeswarm(breast$time_survival, pch = NA)

## Split the data into two groups
x0 <- breast$time_survival[breast$event_survival == 0]
x1 <- breast$time_survival[breast$event_survival == 1]

## Add each group separately
beeswarm(x0, pch = 16, method='center', side =  1, col = 1, at = 1 + xinch(0.04), add = TRUE)
beeswarm(x1, pch = 16, method='center', side = -1, col = 2, at = 1 - xinch(0.04), add = TRUE)

The key parameter is "side", which forces the swarms to expand in only one direction. 关键参数是“侧面”,它迫使群仅在一个方向上扩展。

For the "at" parameter, I used "xinch(0.04)" because this is half of the default space between points (assuming you haven't changed cex or spacing). 对于“ at”参数,我使用了“ xinch(0.04)”,因为这是点之间默认间距的一半(假设您未更改cex或间距)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM