0

I am using plot_bar function in R to illustrate some data from a phyloseq class. I want to add some different colors to my plot, here the pallette Paired from the RColorBrewer package. For some reasons the bars end up still having the default color around them. Here you can see how it looks like: https://i.stack.imgur.com/dBNYr.jpg Any way I could get rid of them?

phylum.both.b <- plot_bar(both.b, fill="phylum") + 
  geom_bar(aes(color=phylum, fill=phylum), stat="identity")  + 
  scale_y_continuous(expand=c(0,0)) + 
  labs(x="", y="Relative abundance")  + 
  scale_fill_brewer(palette="Paired") +
  theme(axis.text.x=element_blank())  + 
  facet_wrap(~Type, scale="free_x", ncol=4) +
  facet_row(vars(Type), scales = 'free', space = 'free')
ggsave("PhylumBothBact.png", phylum.both.b, height=15, width=40, unit="cm")
Flora
  • 3
  • 3

1 Answers1

0

You defined color = phylum in the creation of your plot, but never manually defined the color, so the default is still used. fill fills the bars with color in a bar plot and color outlines the bars.

Try adding scale_color_manual(values = NA)to your plot. Alternatively if you want the outline to match you could use scale_color_brewer(palette = "Paired")

Peter D
  • 171
  • 5
  • As a side note, you can use `geom_col` which has `stat = identity` as the default, instead of needing to define `stat = "identity"` within `geom_bar` – Peter D Jul 28 '20 at 12:41
  • 1
    Thank you so much! I added ```scale_color_brewer(palette = "Paired")``` to the plot and it worked! :D – Flora Jul 28 '20 at 12:42