ggplot 增加箱线图之间的距离

ggplot increase distance between boxplots

如何避免附加箱线图?谢谢

ggplot(df, aes(x=factor(time), y=val, fill=ID))+
geom_boxplot()+
scale_fill_manual(values=c(WT="goldenrod3", KO="steelblue"))

看看position_dodgewidth参数可以帮助间距

mtcars$sep <- 1:2  # a factor

ggplot(mtcars, aes(x=factor(carb), y=mpg, fill=factor(sep))) +
  geom_boxplot(position=position_dodge(width=0.8))