I have a shapefile which I fortified and plotted in ggplot2 using geom_polygon
. How can I plot only a small region of this map?
My full map looks fine, but my small region is messed up.
Here is a working example: This small shapefile can be obtained from:
http://www.mappinghacks.com/data/TM_WORLD_BORDERS_SIMPL-0.2.zip
#read data
spf<-readOGR(getwd(),"TM_WORLD_BORDERS_SIMPL-0.2")
spf@data$id<-rownames(spf@data)
#fortify
spf1<-fortify(spf,region="id")
#full plot
ggplot(spf1)+geom_polygon(aes(long,lat,group=group),colour="grey90")
#subset plot #this is messy since polygons are broken
ggplot(spf1)+geom_polygon(aes(long,lat,group=group),colour="grey90")+
scale_x_continuous(limits = c(-2, 2))+
scale_y_continuous(limits = c(50, 51))
Thanks.
require(rgdal)
require(ggplot2)
– Cheyenne