[R] lattice: strange behavior (?) when using trellis.device(color=FALSE)

Marius Hofert m_hofert at web.de
Sat Nov 27 00:35:47 CET 2010


Dear expeRts,

I am not sure if I found a bug...
I would like to create a function that itself creates a lattice plot without
colors. Following http://www.mail-archive.com/r-help@r-project.org/msg64699.html 
I use trellis.device() to set the colors to FALSE. Whenever I call the minimal
example below *with* trellis.device(), Quartz opens a window (I am working on a
MAC), which it shouldn't, since I only want to create the plot, but do not intend
to "print" it. Moreover, if I check the value of b, it prints the plot (which
is correct) but still with colors. 
Without the trellis.device() call, it works fine (but of course the plot is 
again colored)...
The reason why I would like to use trellis.device() within a function is that 
the plot contains a panel.function which contains many calls to panel.xyplot() 
and I do not want to write "col = 1" (e.g.) all the time...

Cheers,

Marius



library(lattice)

xyplot. <- function(u) { 
	trellis.device(color = FALSE)
	xyplot(u[,2]~u[,1])
}

U <- matrix(runif(20),ncol=2)

b <- xyplot.(U)


More information about the R-help mailing list