Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove connecting lines in ggplot2 geom_polygon

I've made the map below by subsetting a shapefile downloaded from www.gadm.org :

load(url('http://gadm.org/data/rda/GBR_adm0.RData'))
library(ggplot2)
ukMapFort <- fortify(gadm)
ukMapFortSub <- subset(ukMapFort, lat > 55.575 & lat < 55.739 & long > -1.929 & long < -1.7)
ggplot() + geom_polygon(data=data.frame(ukMapFortSub), aes(long, lat, group=id), fill=NA, color="black")

enter image description here

How can I remove the two red lines? Note I've coloured the lines red using Photoshop - these lines are produced by R code, but are not coloured red by R code.

like image 921
luciano Avatar asked Jun 18 '13 13:06

luciano


1 Answers

If you need to plot just borders then you can use geom_path() and column group for group=. You also have to add coord_map() in this case to maintain right aspect ratio between x and y axis.

ggplot(ukMapFortSub,aes(long, lat, group=group))+
  geom_path(color="black")+coord_map()

enter image description here

like image 140
Didzis Elferts Avatar answered Nov 01 '22 05:11

Didzis Elferts