[R] Printing Lattice Graphs from Windows

Deepayan Sarkar deepayan at stat.wisc.edu
Mon Jun 7 08:38:14 CEST 2004


On Sunday 06 June 2004 22:11, Charles and Kimberly Maner wrote:
> Hi.  This did not work for me per my R output/session below:
> > library(lattice)
> > win.metafile()
> > trellis.par.set('background', list('white'))

This doesn't make sense; the components need to be named. Should be 

trellis.par.set('background', list(col = 'white'))

> > trellis.par.set('plot.symbol',list(cex=0.8, col="blue", font=1,
> > pch=1)) 
> > xyplot(1 ~ 1) 
>
> Error in unit(rep(1 * xaxis.cex[1], length(strbar)), "strheight",
> strbar) : x and units must have length > 0

Looks like a completely unrelated bug, which I'll fix. Can be worked 
around by starting the device with 

trellis.device(win.metafile)

> > dev.off()
>
> null device
>           1
>
>
> When I pasted the result into MS Word, I got the same paste--blank. 

Probably due to the error above and not the bug we have been discussing.

> And, yes, another default bg color such as "white" or "transparent"
> would be great as I am definitely not a fan of the standard "gray"
> either.  I researched how to default it to something else, but it
> seems to have to be done manually when a lattice/trellis graph is
> fired up.  Strange, though, as the standard/base graph/plotting does
> default to a "white" background.

Well, the idea is for screen devices to have grey backgrounds and 
'print' devices white. Currently, only pdf, postscript and xfig are 
considered print devices. If the general consensus is that win.metafile 
should also be put into that category, I could probably make the 
necessary changes easily enough.

That said, defaults are just that, and you can change them. In 
particular, calling 

lset(col.whitebg())

before the xyplot call should give a fairly robust scheme with a white 
(or rather 'transparent') background.

Deepayan




More information about the R-help mailing list