A year ago I had posted this code https://stat.ethz.ch/pipermail/r-devel/2005-June/033508.html
and the associated discussion was that there would be a print.trellis argument that could be used to eliminate the need for with.vpPath or with.viewport there. I assume that that is what draw.in= in print.trellis is for. When I try it I get an error. I did notice that ?print.trellis says draw.in= has not been well tested yet. Is this a bug? After running the the code at the end I get this error message: Error in downViewport.vpPath(vpPathDirect(name), strict, recording = recording) : Viewport 'viewport[GRID.VP.1]' was not found The only difference between the code below and the code in the link above (which works) is that in the for loop at the end the 'with' in the code in the link has been removed and draw.in= used in the print call in its place. I am using Windows XP and get similar messages in 2.2.1 and 2.3.0 patched. library(grid) library(lattice) pushLayout <- function(nr, nc, name="layout") { pushViewport(viewport(layout=grid.layout(nr, nc), name=name)) for (i in 1:nr) { for (j in 1:nc) { pushViewport(viewport(layout.pos.row=i, layout.pos.col=j)) upViewport() } } upViewport() } names.vpPath <- names.viewport <- function(x) x$name with.vpPath <- with.viewport <- function(data, expr, ...) { # if data is a vpPath it cannot be ROOT since # NULL will never dispatch here depth <- if (data$name == "ROOT") 0 else downViewport(names(data)) result <- eval.parent(substitute(expr)) upViewport(depth) invisible(result) } getChildren.viewport <- function(x) x$children grid.newpage() # specify number of cells to fill and number of rows n <- 5; nr <- 3 nc <- ceiling(n/nr) downViewport(pushLayout(nr, nc)) vpt <- current.vpTree(all = FALSE) for(k in 1:n) print( xyplot(v ~ v, list(v = 1:k)), newpage = FALSE, draw.in = getChildren.viewport(vpt)[[k]] ) ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel