Sunday 27 November 2016

polygon - Overlaying a polyshape to faceted maps in R with ggplot?


I have managed to create a faceted map from my data following the approach proposed here http://spatial.ly/2013/12/introduction-spatial-data-ggplot2/ with the following code:


ggplot(data = plot.data, aes(x = long, y = lat, fill = value, group = group)) + 
geom_polygon() + coord_equal() +
facet_wrap(~variable,labeller = as_labeller(names), ncol=2)

Where


plot.data <- merge(bound.f, mdata.melt, by.x = "id", by.y = "uid")


and bound.f is the fortified spatial polyshape (with sub-national boundaries) and mdata.melt is the data used in map, in the the long format.


And I get the following output:


output map :In case you don't see, it is the African continent


So far so good. Now I would like to add (overlay) the boundaries of the African countries (which I have a shapefile, same projection than bound) to both maps.


In other words, I want to add the shape, which boundaries should be black and the shape with no fill.


Does anyone have a hint on how I could code this or even has a smarter approach to get beautiful maps into my publication?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...