[R] Error in multiple xyplots

Roger D. Peng rpeng at jhsph.edu
Mon Feb 23 17:16:12 CET 2004


You cannot use par(), which is part of the base graphics system, with 
xyplot(), which is part of the lattice/grid system.  If you want to 
combine base-graphics with lattice/grid you need to use the `gridBase' 
package on CRAN.

-roger

Rodrigo Abt wrote:
> Dear R-listers,
> 
> I got an error when I try to plot two grouped data into a single
> win.metafile device:
> 
> library(lattice)
> trellis.device(device="win.metafile",color=F,filename="Profiles-Var1.wmf")
> par(mfrow=c(1,2))
> 
> # First plot
> xyplot(log(v)~t|id,data=Con.20,
> main="Group A: Control, Var-1",
> xlab="ocasion",ylab="var1",
> panel=function(x,y) {
> 	m<-sort.list(x)
> 	panel.grid()
> 	panel.xyplot(x[m],y[m],type="b",cex=0.8)
> 	}
> )
> 
> # Second plot
> xyplot(log(v)~t|id,data=Trt.20,
> main="Group B: Treat, Var-1",
> xlab="ocasion",ylab="var1",
> panel=function(x,y) {
> 	m<-sort.list(x)
> 	panel.grid()
> 	panel.xyplot(x[m],y[m],type="b",cex=0.8)
> 	}
> )
> 
> When then last plot is entered, a messagebox pops up an says "Unable to
> create metafile", and R shutdowns. However, if I use simple plots instead of
> xyplots, then it works:
> 
> trellis.device(device="win.metafile",color=F,filename="Simple-Plots.wmf")
> par(mfrow=c(1,2))
> 
> # First plot
> plot(1:10,rnorm(10),main="Plot 1")
> 
> # Second plot
> plot(1:10,rnorm(10),main="Plot 2")
> 
> No error, so I call dev.off() and the file generated is OK.
> 
> I tried plotting the data in separate 'win.metafile' devices (files) and
> worked perfect. I've read the R help, googled around and searched the R-list
> for a similar problem and found nothing...any clues ?
> 
> I'm working with win2K and R-1.8.1.
> 
> Regards,
> 
> Rodrigo Abt B,
> Analyst,
> Dept. Economic Studies,
> SII, Chile.
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list