I want to change the colours of the bars of my bar chart, which has 15 bars. I have already used the scale_fill_discrete() function to change the title of my legend. When I now use the scale_fill_brewer() function I get the error: "Scale for fill is already present. Adding another scale for fill, which will replace the existing scale.".

bclu22 <- lu22 %>%
  ggplot(aes(x=LanduseType, y=BurrowIndexEP, fill = PlotID))+
  geom_bar(stat="identity", color="black", position=position_dodge(width=0.88), width=0.8)+
  scale_fill_discrete(name="Grassland")+
  scale_fill_brewer(palette="Set3")+
  theme_bw(base_size = 11)+
  xlab("Landuse Type")+
  ylab("Burrow Index EP") 

Can I perhaps somehow pack both in the scale_fill_manual() function? When I try this, I get the error: "Error in self$palette(n) : attempt to apply non-function". In addition, the package RColorBrewer does not have a colour palette of 12 colours. I can't find a solution for this either.

bclu22 <- lu22 %>%
  ggplot(aes(x=LanduseType, y=BurrowIndexEP, fill = PlotID))+
  geom_bar(stat="identity", color="black", position=position_dodge(width=0.88), width=0.8)+
  scale_fill_manual(name="Grassland",
                    palette="Set3")+
  theme_bw(base_size = 11)+
  xlab("Landuse Type")+
  ylab("Burrow Index EP")
0

There are 0 best solutions below