Grouped bar graph custom colours

后端 未结 1 583
野的像风
野的像风 2020-12-10 22:58

I have the following data and wish to create a grouped bar graph like so:

data<-as.data.frame(c(\"a\",\"b\",\"c\",\"a\",\"b\",\"c\"))
colnames(data)<-\         


        
相关标签:
1条回答
  • 2020-12-10 23:20

    You need to get group and fill mapped to the right variable:

    ggplot(data, aes(x=X, y=Z, group=Y, fill=X)) +
             geom_bar(stat="identity", colour="black", position="dodge", size=0.25, width=0.8, alpha=0.8) + 
      scale_fill_manual(values=c("red","blue"))
    

    enter image description here

    0 讨论(0)
提交回复
热议问题