[R] Printing Lattice Graphs from Windows

Duncan Murdoch dmurdoch at pair.com
Mon Jun 7 03:47:22 CEST 2004

On Sun, 06 Jun 2004 17:43:42 -0700, Spencer Graves
<spencer.graves at pdf.com> wrote:

>Hi, Deepayan: 
>      Following your suggestion, I tried the following in Rgui.exe: 
> > xyplot(1~1)
> > win.metafile()
> > graphics.off()
>      I then switched to MS Word, pasted, and got the same blank plot as 
>before.  (I actually tried other things as well, but came to this after 
>reading the documentation.) 

You should open the device *first*.  Then you plot to it, then close
it and the graphics are saved.

That is,

> library(lattice)
> win.metafile()
> xyplot(1 ~ 1)
> dev.off()

This worked for me in a single attempt; I haven't tested it

Generally speaking, you get better graphics results by plotting to the
final graphics device rather than plotting to the screen and copying
somewhere, because the graphics system makes some choices based on the
target device capabilities, and those choices might not be appropriate
on a different device.  I notice lines are often too thin when printed
from a plot on screen, for example.

Duncan Murdoch

More information about the R-help mailing list