Why is ggplot using default colors when others are specified?

前端 未结 2 1878
春和景丽
春和景丽 2021-01-14 16:28

I am trying to have ggplot2 show one line of a histogram as a different color than the rest. In this I have been successful; however, ggplot is using the default colors whe

2条回答
  •  一个人的身影
    2021-01-14 16:47

    I don't think you can explicitly set colors in aes; you need to do it in scale_fill_manual, as in the example below:

    ggplot(dist.x, aes(x = sim_con)) +
      geom_histogram(colour = "black", binwidth = .01,aes(fill=(sim_con==1.55))) + 
      scale_fill_manual(values=c('TRUE'='darkgreen','FALSE'='firebrick')) +
      theme(legend.position="none")
    

    enter image description here

提交回复
热议问题