title: ggplot2 facet plot of shapefile polygons produces strange lines
body: <p>I'm working to produce a facet/lattice plot of choropleth maps that each show a how different model runs affect one variable being mapped across a number of polygons. The problem is that the output graphic produces strange lines that run between the polygons in each plot (see the graphic below).</p>
  
  <p>While I've manipulated and converted the shapefile into a data frame with appropriate attributes for ggplot2, I'm not familiar with the details of how to use the package and the online documentation is limited for such a complex package. I'm not sure what parameter is causing this issue, but I suspect it may be the aes parameter.</p>
  
  <p>The script:</p>
  
  <pre><code>library(rgdal, tidyr, maptools, ggplot2, dplyr, reshape2)
  
  setwd('D:/path/to/wd')
  
  waterloo &lt;- read.table("waterloo-data.txt", header=TRUE, sep=',', stringsAsFactors=FALSE)
  waterloo &lt;- data.frame(waterloo$DAUID, waterloo$LA0km, waterloo$LA4_exp, waterloo$LA20km, waterloo$LA30km, waterloo$LA40km, waterloo$LA50km)
  colnames(waterloo) &lt;- c("DAUID", "LA0km", "LA10km","LA20km", "LA30km", "LA40km", "LA50km")
  
  ## Produces expenditure measurements by ID variable DAUID, using reshape2/melt
  wtidy &lt;- melt(waterloo, id.vars=c("DAUID"), measure.vars = c("LA0km", "LA10km", "LA20km", "LA30km", "LA40km", "LA50km"))
  colnames(wtidy) &lt;- c("DAUID", "BufferSize", "Expenditure")
  
  wtidy$DAUID &lt;- as.factor(wtidy$DAUID) # for subsequent join with wtrl_f
  
  ### READ SPATIAL DATA ###
  #wtrl &lt;- readOGR(".", "Waterloo_DA_2011_new")
  wtrl &lt;- readShapeSpatial("Waterloo_DA_2011_new")
  wtrl$id &lt;- row.names(wtrl)
  
  wtrl_f &lt;- fortify(wtrl)
  wtrl_f &lt;- left_join(wtrl_f, wtrl@data, by="id")
  
  # Join wtrl fortified (wtrl_f) to either twaterloo or wtidy
  wtrl_f &lt;- left_join(wtrl_f, wtidy, by="DAUID")
  
  ### PLOT SPATIAL DATA ###
  ggplot(data = wtrl_f, # the input data
         aes(x = long.x, y = lat.x, fill = Variable/1000, group = BufferSize)) + # define variables
    geom_polygon() + # plot the DAs
    geom_path(colour="black", lwd=0.05) + # polygon borders
    coord_equal() + # fixed x and y scales
    facet_wrap(~ BufferSize, ncol = 2) + # one plot per buffer size
    scale_fill_gradient2(low = "green", mid = "grey", high = "red", # colors
                         midpoint = 10000, name = "Variable\n(thousands)") + # legend options
    theme(axis.text = element_blank(), # change the theme options
          axis.title = element_blank(), # remove axis titles
          axis.ticks = element_blank()) # remove axis ticks
  </code></pre>
  
  <p>The output graphic appears as follows:</p>
  
  <p><img src="https://i.stack.imgur.com/UyauH.png" alt="enter image description here">
  Strange! I've made good progress but I don't know where ggplot is getting these lines. Any help on this would be appreciated!</p>
  
  <p>PS; as an additional unrelated question, the polygon lines are rather jagged. How would I smooth these lines?</p>