[R] 'Extracting' plot area
Duncan Murdoch
murdoch at stats.uwo.ca
Wed May 21 16:03:21 CEST 2008
On 5/21/2008 9:02 AM, Tine wrote:
> Hi!
>
> Does anyone know hot to save (to png, pdf, ...) only plot area. That is
> without box around, titles, axis, ...
> I tried: par(mar=c(0,0,0,0)) and it works for internal viewer (linux and
> windows).
> But when I save the image in png it adds that annoying margin around
> plot area.
> Any ideas?
Set up the options for no margins after opening the device. (If you are
copying from the screen device in Windows, you don't need to do it
again; presumably the same is true in Linux. But if you use png() to
open a png device it will start up with default par settings. You need
to set the margins after that.)
For example,
> png("test.png")
> par(mar=c(0,0,0,0), xaxs="i", yaxs="i")
> plot(runif(10000))
> dev.off()
produces a big ugly plot without those nice margins.
Duncan Murdoch
More information about the R-help
mailing list