Removing border/outline of colour fill for barplot (scale_fill_manual ggplot2)

162 Views Asked by At

I'm creating a barplot using ggplot2, and when I change the colour palette using scale_fill_manual, it is putting borders around the colour fill, so some of the values, particularly the smaller percentages, are difficult to see or completely obscured.

I'm plotting % of samples made up of different fungal phyla. The data is from a phyloseq object, where I summed the relative abundance of different phyla then transformed to a dataframe as I have more experience working with df objects in ggplot2. Example of how the data is organised: Sample Data

The code I'm using to make the boxplot:

scat.melt%>%
  ggplot()+
  geom_bar(aes(y=Abundance, x=Sample, color=Phylum, fill=Phylum), stat="identity", position="stack")+
  facet_wrap(~ReleaseTime, scales="free")+
  theme(panel.background = element_blank(), axis.text.x=element_blank(), axis.ticks.x=element_blank(), strip.background = element_rect(fill="white"))+
ylab("Relative Abundance (%)\n")+
scale_fill_manual(values=colorBlindGrey8)

scale_fill_manual plot with unwanted borders

It is exactly what I want except for the lines- I was thinking that it is because in the data rows the phyla are broken up into their OTU's, so they are still being represented as discrete groups in the barplot although they are the same phyla so still represented as the same colour. However when I remove the scale_fill_manual argument, and use the default colour palette, I don't have this issue (there are no borders around the colours).

default colour palette plot

I also thought applying a group_by argument to the dataframe before plotting would potentially help, so tried that:

scat.melt<-scat.melt %>%
  group_by(pick(ReleaseTime, Phylum, Sample))

To no avail.

0

There are 0 best solutions below