I have made the following map, which I am fairly happy with. However, I cannot successfully produce a legend for it. Is there any way that a manual legend can be made in this case?
I have been trying to use scale_fill_manual, but this doesn't work. I am assuming this is because I've built the plot up from multiple, separate polygons, and as such there is not one dataset to refer to for the legend colors.
If there is an way to make a legend from separate polygons, I would be happy to get your advice! This question seems similar, but the solution involves creating a dataset of a subset of countries from worldmaps, and I haven't been able to wrap my head around how to do that for m polygons that are not already part of one cohesive set of data.
gabon <- ggplot() +
geom_polygon(data = gabon0.fortified, aes(x = long, y = lat, group = group), #gabon background
fill="#E7D4E8", color=NA) +
geom_polygon(data = permits.fortified, aes(x = long, y = lat, group = group), #logging permits
fill="#CCEEFF", color="#006191", size = 0.15, show.legend=TRUE) +
geom_polygon(data = parks.fortified, aes(x = long, y = lat, group = group), #parks
fill="#CCDDAA", color="#4e6127", size = 0.15, show.legend=TRUE) +
geom_polygon(data = tc.subset.f, aes(x = long, y = lat, group = group), #seef
fill="#fef7ab", color="#5a5301", size = 0.3, show.legend=TRUE) +
geom_polygon(data = one.fortified, aes(x = long, y = lat, group = group), #seef
fill="#fef7ab", color="#5a5301", size = 0.3, show.legend=TRUE) +
geom_polygon(data = before.fortified, aes(x = long, y = lat, group = group), #seef
fill="#fef7ab", color="#5a5301", size = 0.3, show.legend=TRUE) +
geom_polygon(data = gabon0.fortified, aes(x = long, y = lat, group = group), #gabon outline
fill=NA, color="black") +
scale_fill_manual("Land area types", values = c("SEEF" = "#fef7ab",
"Logging permits" = "#CCEEFF",
"Protected areas" = "#CCDDAA",
"Gabon" = "#E7D4E8"),
breaks = c("SEEF", "Logging permits", "Protected areas", "Gabon")) +
labs(title = "Gabon logging permit and protected areas", x = "latitude", y = "longitude",
color = "Land areas") +
theme_minimal() + theme