ggplot增加箱形图之间的距离 [英] ggplot increase distance between boxplots

查看:974
本文介绍了ggplot增加箱形图之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能避免附上盒子图?谢谢

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

$ c> position_dodge , width 参数可以帮助间距

  mtcars $ sep < -  1:2#a因子

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


How can I avoid attached box-plots? Thank you

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

解决方案

Look at position_dodge, the width argument can help with spacing

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

这篇关于ggplot增加箱形图之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆