Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why custom colors without scale_fill_identify does not work in ggplot?

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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 –

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading