I use ggplot and I want to overlay two bar plots. Here is my head dataset: (data = csv_total)
habitates surf_ha obs_flore obs_faune
1 Régénération de feuillus 0.4 0.0 2.4
2 Villes, villages et sites industriels 0.7 0.0 15.6
3 Forêt de feuillus 384.8 1.1 0.0
4 Forêt de Pin d'alep 2940.8 2.1 1.0
5 Maquis 45.9 2.3 0.3
6 Plantation de ligneux 306.4 2.5 1.0
Here are my 2 bar plots:
hist1 <- ggplot(csv_total, aes(x = habitates, y = obs_flore)) + geom_bar(stat = "identity") +
theme(axis.text.x= element_text(angle=50, hjust = 1))
hist2 <- ggplot(csv_total, aes(x = habitates, y = obs_faune)) + geom_bar(stat = "identity") +
theme(axis.text.x= element_text(angle=50, hjust = 1))
X axis represents habitates and the Y axis represents the number of observations (flora for hist1 and fauna for hist2).
So I would like to create a single bar plot by overlaying both. In order to obtain in X axis : the habitats and in Y axis : the floristic observations and the faunistic observations in two different colors. Do you have an idea to overlay these barplots together in one?
Sry for my bad english. Thanks!