Re: [R] Graphics 'snapshots' in Linux?

From: Marc Schwartz (via MN) <mschwartz_at_mn.rr.com>
Date: Fri 16 Sep 2005 - 02:31:16 EST

On Thu, 2005-09-15 at 10:43 -0400, Tyler Smith wrote:
> Hi,
>
> I'm working on a MEPIS (Debian-based Linux) computer, using the
> emacs/ESS package to do my R work. I've got some plots that I label
> interactively using the locate function. With the Windows GUI there is
> an option to take a snapshot of the graphics output, saving it as an
> image file. Is there a way to do this with emacs/ESS?
>
> Thanks,
>
> Tyler

Tyler,

Take a look at ?dev.copy2eps and on the same page dev.copy(), which enable you to copy the current X11 plot supported output devices.

You could do something like the following for an EPS file:

plot(1:5)
text(locator(1), "Place Text Here")
dev.copy2eps(file = "MyPlot.eps")

or the following for a PNG file:

par(bg = "white")
plot(1:5)
text(locator(1), "Place Text Here")
dev.copy(device = png, file = "MyPlot.png") dev.off()

Note that in the first example, dev.off() is not required, as the EPS output device is closed after the call.

Also, note in the second example, you will need to set the background to white (unless already specified for whatever color you may be using), as the default output file will have a transparent background, even though the png() function shows the default as white. If my memory is correct this is because the X11 device itself has a transparent background by default and this is what is copied.

HTH, Marc Schwartz



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Sep 21 03:11:13 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 17:29:03 EST