On Mon, Jun 14, 2010 at 6:24 PM, Martin Maechler <maech...@stat.math.ethz.ch> wrote: > Dear Deepayan, > > this is in reply to a message almost 6 months ago : > >>>>>> Deepayan Sarkar <deepayan.sar...@gmail.com>
[...] > > Thanks, I was going to say the same thing, except that it would be > (1) > > conceptually simpler just to add the 'i' and 'j' values as arguments > > to the "panel" function (the 'pargs' variable). The colors could then > > be passed through as part of the ... arguments, and the relevant entry > > extracted in the panel function. > (2) > > The other option is to keep a global counter and increment it inside > > the panel function, and choosing colors based on that counter and > > knowledge of the order in which panels are drawn. Not very elegant, > > but the least intrusive solution I can think of. > > > -Deepayan > > Against the R-forge version of lattice, > the following very small patch to panel.pairs > would allow users to use '(1)' i.e., provide panel functions > with (i,j) arguments directly. > I'm pretty sure that the change could not easily break existing > splom() usage. > > --- R/splom.R (revision 619) > +++ R/splom.R (working copy) > @@ -291,7 +291,8 @@ > y = z[subscripts, i]), > ## panel.number = panel.number, > ## packet.number = packet.number), > - list(...)) > + list(...), > + list(i = i, j = j)) > else > c(list(x = z[subscripts, j], > y = z[subscripts, i], > @@ -299,7 +300,8 @@ > subscripts = subscripts), > ## panel.number = panel.number, > ## packet.number = packet.number), > - list(...)) > + list(...), > + list(i = i, j = j)) > > if (!("..." %in% names(formals(panel)))) > pargs <- pargs[intersect(names(pargs), > names(formals(panel)))] Done in r-forge svn. -Deepayan > > > With the above change, > a user could use a panel function with (i,j) arguments, > and e.g. say > > Cmat <- outer(1:6,1:6, > function(i,j) rainbow(11, start=.12, end=.5)[i+j-1]) > > splom(~diag(6), ## for testing: superpanel=mypanel.pairs, > panel=function(x,y,i,j,...){ > panel.fill(Cmat[i,j]); panel.splom(x,y,...) > panel.text(.5,.5, paste("(",i,",",j,")",sep="")) > }) > > > I think that would allow quite a bit more flexibility without > the need to explicitly "hack" panel.pairs > (and having to maintain such a hack against the ever-enhancing > lattice). > > Martin Maechler, ETH Zurich > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.