I have written the code to make bar charts for the counts of species in four habitat types. I have 8 species in total but not all species are present in each habitat. I want a multi-paneled graph of the four habitat types with a common legend for the species. Currently, each of bar charts has it's own legend with different colours corresponding to different species.
[Graph of RV][1]
[Graph of CG][2]
[Graph of U][3]
[Graph of SRG][4]
Below is the code used
ggplot(SRG, aes(x = Species)) +
geom_bar(aes(color = Species),
stat = "count", position = position_dodge(0.8),
width = 0.9)+
labs(y= "Count", x= "Species")
ggplot(U, aes(x = Species)) +
geom_bar(aes(color = Species, , fill = Species),
stat = "count", position = position_dodge(0.8),
width = 0.9)+
labs(y= "Count", x= "Species")
ggplot(CG, aes(x = Species)) +
geom_bar(aes(color = Species, fill = Species),
stat = "count", position = position_dodge(0.8),
width = 0.9)+
labs(y= "Count", x= "Species")
ggplot(RV, aes(x = Species)) +
geom_bar(aes(color = Species, fill = Species),
stat = "count", position = position_dodge(0.8),
width = 0.9)+
labs(y= "Count", x= "Species")