title: Remove PNG plot margins
body: <p>I am trying to get rid of the top and bottom margins of a SpatialPolygons plot.
  I have tried setting the margins to c(0,0,0,0) but this only changes the left and right margins.</p>
  
  <p>When plotting in RStudio, the top and bottom margins are 0 but the left and right are not.</p>
  
  <pre><code>library(sp)
  
  coords &lt;- cbind(c(631145, 631757, 631928, 631664, 631579, 631281),
                  c(6967640, 6967566, 6968027, 6967985, 6968141, 6968009))
  poly &lt;- Polygons(list(Polygon(coords)),"coords")
  poly.sp &lt;- SpatialPolygons(list(poly))
  
  par(mar = rep(0, 4), xaxs='i', yaxs='i')
  plot(poly.sp, bg="yellow")
  
  png('poly.png')
  par(mar = rep(0, 4), xaxs='i', yaxs='i')
  plot(poly.sp, bg="yellow")
  dev.off()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/ybyuO.png" alt="plot"></p>