I have created a graph in R with ggplot
, which shows the different groups of phytoplankton over the years. Now it have been requested to remove a group from the legend, because they cannot really been seen in the graph (for eg. "Cyanobacteria"). My question is this possible? If yes how?
My data:
My code:
if(!require(pacman)){install.packages("pacman")}
pacman::p_load(DT,leaflet,leaflet.extras,readxl,htmlwidgets,plotly,dplyr,lubridate,vegan,zoo,
ggplot2,reshape2,sciplot,psych,RColorBrewer)
df<-read_excel("C:/wherever")
attach(df)
colourCount=length(unique(df$Phytoplankton))
getPalette = colorRampPalette(brewer.pal(12, "Paired"))
p<-ggplot(data=df, aes(x=Year, y=Abu, fill=Phytoplankton))+geom_bar(stat="identity",color="black", width =1)
p<-p+scale_fill_manual(values = getPalette(colourCount))
p<-p+labs(title="Phytoplanktondichte",x="Jahr", y = "Individuendichte (Ind/L)")
p<-p+theme_minimal()
p
I found out how to change the colour, the position, the title basically everything, but I coundn´t fine anything in how to remove something from the legend.
I would really appreciate your help.