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 are my ggplot fill colors not showing?

I’ve already looked at several plausible options, but none seem to address my bug. Here are the three closest I found:

1
2
3

When I create a stacked 100% horizontal barplot, the individual components show as uniform grey. I want to use scale_color_brewer(type = "qual", palette = "Paired"), but it doesn’t work. I continue getting the same output (no error messages).

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

Frustrating Resultant Image

This is the data file and my code (none of the four fill methods shown in this block worked for me):

Logan <- read.csv('Logan3.csv', fileEncoding = "UTF-8-BOM")

mancol <- c("#a6cee3", "#1f78b4", "#b2df8a", "#33a02c")

Logan %>% ggplot(
  aes(x=Locations, y = Percent, Fill = Tasks)
  ) +
    geom_bar(stat = 'identity', position = "stack") +
    coord_flip() +
    scale_fill_manual(values=mancol)
    #scale_fill_brewer(palette = "Set1")
    #scale_fill_manual(c("#a6cee3", "#1f78b4", "#b2df8a", "#33a02c"))
    #scale_color_brewer(type = "qual", palette = "Paired")

>Solution :

As @stefan said in the comments, it’s just a typo: use fill = Tasks, not Fill.

Changing that fixes the problem immediately.

enter image description here

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