Skip to content

two lattice graphs in one object

3 messages · Andreas Krause, Felix Andrews, Deepayan Sarkar

#
Deepayan,

that is exactly what I was hoping for. Thanks much!

Experimenting with it I noticed that updating two existing objects with plot arguments seems to not work, at least not in this way:

gr1 <-xyplot(rnorm(111) ~ runif(111), main = "Plot A")
gr2 <- xyplot(runif(111) ~ runif(111), main = "Plot B")

plist <- list(
  update(gr1, plot.args = list(position = c(0, 0, 1, 0.5), more = TRUE)),
  update(gr2, plot.args = list(position = c(0, 0.5, 1, 1), more = FALSE))
)

print(plist)
gives me two separate pages, even though the object is updated:
$plot.args
$plot.args$position
[1] 0.0 0.0 1.0 0.5

$plot.args$more
[1] TRUE

I can get it to work the "dirty" way:
plist[[1]]$plot.args <-  list(position = c(0, 0, 1, 0.5), more = TRUE)
plist[[2]]$plot.args <-  list(position = c(0, 0.5, 1, 1), more = FALSE)

Shouldn't update work as well? 
(R version 2.6.2, platform i386-pc-mingw32)

Thanks again!

  Andreas

 On Tue Sep  2 21:43 , "Deepayan Sarkar"  sent:
#
By the way, a different approach, with a different result, is to use
c.trellis from the latticeExtra package:

library(latticeExtra)
...
return(c(gr1, gr2))

This merges the panels into a single trellis object. Note that there
are complications with things like titles, legends and strips.

-Felix

2008/9/3 Andreas Krause <andreas at elmo.ch>:

  
    
#
On Tue, Sep 2, 2008 at 11:43 PM, Andreas Krause <andreas at elmo.ch> wrote:
Yes, it should; but update() predates 'plot.args' etc. and wasn't
updated; it treats 'plot.args' as an unrecognized argument and adds it
to the list of panel function arguments. I'll fix this in the next
release.

-Deepayan