Home > other >  Why custom colors without scale_fill_identify does not work in ggplot?
Why custom colors without scale_fill_identify does not work in ggplot?

Time:01-15

I'm trying to understand, why my graph shows appropriately when scale_fill_identity is used ?

ggplot(data = result, aes(x = date, y = diffinPercentages))   geom_col(  aes(fill= cond))   scale_fill_identity() 

enter image description here If I leave out scale_fill_identity, then the graph does not show custom colors. Instead, ggplot makes up color of its own

   ggplot(data = result, aes(x = date, y = diffinPercentages))   geom_col(  aes(fill= cond)) 

enter image description here What does scale_fill_identify do to make sure custom colors are properly shown?

CodePudding user response:

The scale_fill_... functions determine the scale used for the fill aesthetic, which would be the color used. If you don't include it, it uses the default ggplot color scale.

By providing a scale_fill_... function, you replace the default color scale with one of your choice –

  •  Tags:  
  • Related