简体   繁体   中英

ggplot increase distance between boxplots

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM