rphyloseq

Removing the original color outline in R when using a new pallette in a barplot


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.sstatic.net/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")

Solution

  • 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")