是否有可能画出一个令人不快的情节,使得逐点颜色在水平中心对齐? (我相信这会提高可读性,特别是如果数据不像示例那样明确。)
使用居中颜色实现此绘图:
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)
它很接近,但各个地块上的各个点并不完全相同。
答案 0 :(得分: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)
关键参数是“侧面”,它迫使群体仅向一个方向扩展。
对于“ at”参数,我使用了“ xinch(0.04)”,因为这是点之间默认间距的一半(假设您未更改cex或间距)。