[Rd] Re: [R] Problem going back to a viewport with gridBase

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Wed 01 Jun 2005 - 01:21:24 GMT

[moved from r-help to r-devel]

On 5/31/05, Paul Murrell <p.murrell@auckland.ac.nz> wrote:

> > # mm.row[j] gives the row in the layout of the jth cell
> > # mm.col[j] gives the col in the layout of the jth cell
> > mm <- matrix(seq(nr*nc), nr, nc)
> > mm.row <- c(row(mm))
> > mm.col <- c(col(mm))
> >
> > # go to next cell in the array
> > j <- j + 1 # increment position
> > pushViewport(viewport(layout.pos.row = mm.row[j], layout.pos.col = mm.col[j]))
> >
> > Is that how to do it or is there some layout/mfcol-like way?
>
>
> That is how to do it.
>
> As far as grid is concerned, all viewports are equal and grid has no
> idea whether a viewport corresponds to a "plot region" or a "margin" or
> whatever, so grid has no concept of which viewport is the "next" one to use.
>

OK. Thanks. One suggestion. Maybe the cells in a layout could have an order to them and there could be an optional argument that takes a linear index directly allowing easy linear traversals:

for(i in seq(nr*nc)) {

   pushViewport(viewport(i)) # might need different syntax here    xyplot(seq(i) ~ seq(i))
   popViewport()

}

and taking it one further perhaps 'with' could have a viewport method that automatically pushes the viewport on entry and pops or moves up one level on exit reducing the above to:

for(i in seq(nr*nc)) with(viewport(i), xyplot(seq(i) ~ seq(i)))



R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Jun 01 11:24:08 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:06 GMT