如何更改beeswarm情节的离散x轴的顺序?

时间:2015-09-30 10:26:30

标签: r

我正在使用beeswarm来绘制我的数据。

d<-data.frame(Cond=c(WT,WT,KO,KO),Count=c(1,2,3,4))
beeswarm(Count ~ Cond, data = d)

这会产生以下图像。

enter image description here

如何手动指定x轴,以便WT在KO之前出现?

2 个答案:

答案 0 :(得分:2)

d<-data.frame(Cond=c("WT","WT","KO","KO"),Count=c(1,2,3,4))

#turn into a factor with manual specification of levels
d$Cond <- factor(d$Cond,levels=c("WT","KO"))


#plot
beeswarm(Count ~ Cond, data = d)

enter image description here

答案 1 :(得分:1)

有很多关于here

的内容
d<-data.frame(Cond=c('WT', 'WT', 'KO', 'KO'),Count=c(1,2,3,4))
    library(beeswarm)

    beeswarm(Count ~ Cond, data = d)

    f <- ordered(d$Cond, levels = c("WT", "KO"))
    beeswarm(Count ~ f, data = d)