[R] panel function problem with ps

Andy Bunn abunn at montana.edu
Mon Jun 2 23:20:50 CEST 2003


Hi, I have an elaborate coplot for which I had to write my very first
panel statement. It looks fine on the screen (in an x11 device) but does
not go to postscript correctly. Not even close actually. This is the
only one of my r scripts that hasn't run perfectly under linux and I'm
generally very pleased at how smoothly the transistion has been from R
under windows to ESS-style R.

However, I've made this plot under windows and saved it just fine and am
ready to admit a problem with my panel function. I'm just not sure what
it is. 

The coplot is a double conditioning plot and I'm adding a spline to each
panel. So, I'm trying to use the subscripts argument.

#~~~~~~~~~~~~~~~~~~~~~~~~~~~
postscript("foo.ps")
coplot(x.var ~ y.var | m.var * n.var,
       given.v = list(m.var.overlap, n.var.overlap),
       subscripts = T, aspect = "xy",
       panel = function(x, y, subscripts, ...){

       #Add points
       points(x, y, col = "gray50")

       #Make and draw a spline in each panel
       spline.model <- smooth.spline(y.var[subscripts],
                                     x.var[subscripts])
       thefits <- predict(spline.model, y.var)$y
       sp <- spline(x, thefits[subscripts])

       #Add lines
       lines(sp$x, sp$y, col = "black", lwd = 4)
       })
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Any help appreciated.

-Andy




More information about the R-help mailing list