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).

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

Leave a Reply