1

是否可以绘制一个蜂群图,使逐点颜色在水平中心对齐?(我相信这会大大提高可读性,特别是如果数据不像示例中那样清晰。)

要使用居中颜色实现此图:

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

我试过了:

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

它很接近,但各个图上的各个点并不完全相同。

4

1 回答 1

0

我认为你在正确的轨道上。这是一种方法:

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)

关键参数是“side”,它迫使蜂群仅向一个方向扩展。

对于“at”参数,我使用了“xinch(0.04)”,因为这是点之间默认空间的一半(假设您没有更改 cex 或间距)。

于 2018-07-27T13:40:19.500 回答