[R-sig-Geo] Excessive whitespace in saved images from sp::plot()

VIRGILIO GOMEZ RUBIO Virgilio.Gomez at uclm.es
Wed Dec 16 23:24:57 CET 2015


> El 16/12/2015, a las 19:35, Matt Strimas-Mackey <strimas at zoology.ubc.ca> escribió:
> 
> After messing around with parameters aimlessly I managed to solve my
> problem.
> 
> The key seems to be that par(mar=c(0, 0, 0, 0)) needs to come AFTER
> png('plot.png')
> as in:
> png('plot.png')
> par(mar=c(0, 0, 0, 0))
> plot(square, axes = F, lwd = 2, asp = "", xpd = NA)
> dev.off()
> 
> I have no idea why this is the case, but it works!


Matt,

png() opens a new device with different settings:

> par(mar = c(0, 0, 0, 0))
> par()$mar
[1] 0 0 0 0
> png(file = "test.png")
> par()$mar
[1] 5.1 4.1 4.1 2.1

That is why you need to call par() after png().

Best,

Virgilio


More information about the R-sig-Geo mailing list