Generate ggplot2 boxplot with different colours for multiple groups

旧时模样 提交于 2019-11-29 00:02:35

You should use interaction() for the fill= and provide both Species and Experiment inside interaction(). Then with scale_fill_manual() you can set values= for the colors you need (number of colors correspond to number of box-plots). Order of colors is, first, colors for Species in Autumn then colors for Species in Spring.

ggplot(DF, aes(Species, Protein, fill=interaction(Species,Experiment), dodge=Experiment)) +
  stat_boxplot(geom ='errorbar')+
  geom_boxplot()+
  scale_fill_manual(values=c("blue","green","red","cyan",
             + "darkblue","darkgreen","darkred","darkcyan"))

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!