ggplot增加箱线图之间的距离

时间:2015-09-01 23:53:21

标签: r ggplot2 boxplot

如何避免附加盒子图?谢谢

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

enter image description here

1 个答案:

答案 0 :(得分:4)

查看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))