[R] graphing plots of plots

baptiste auguie baptiste.auguie at googlemail.com
Sat Aug 21 22:15:14 CEST 2010


Hi,


I think you could do it quite easily with lattice,

library(lattice)

latticeGrob <- function(p, ...){
   grob(p=p, ..., cl="lattice")
}
drawDetails.lattice <- function(x, recording=FALSE){
   lattice:::plot.trellis(x$p, newpage=FALSE)
}

plots <- replicate(4, xyplot(rnorm(10)~rnorm(10),xlab="",ylab=""), simplify=F)

my.vp <- function(x,y)
viewport(x=x,y=y,default.units="native",width=unit(1, "cm"),
height=unit(1,"cm"))

my.panel = function(x, y, ...){
  ind <- seq_along(x)
  for (ii in ind){
    g <- latticeGrob(plots[[ii]], vp=my.vp(x[ii],y[ii]))
    grid.draw(g)
  }
}

xyplot(1:4~1:4, panel = my.panel)

HTH,

baptiste

On 21 August 2010 22:11, Barry Rowlingson <b.rowlingson at lancaster.ac.uk> wrote:
> On Sat, Aug 21, 2010 at 8:48 PM, r.ookie <r.ookie at live.com> wrote:
>> I'm trying to understand your question because when I think of a graph, I think of one canvas, on which, various functions are plotted (a function can be one point for example).
>>
>> So, when you say each 'element' do you mean each function?
>> If so, then that seems to be asking how to plot a function per graph (which is probably obvious and not what you're asking)
>>
>> How about you clarify first :)
>>
>
>  Sounded to me a bit like plotting pie charts at the locations of
> countries on a map. Or something better (not hard).
>
>  subplot from Hmisc?
>
>  library(Hmisc)
>  example(subplot)
>
> Barry
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list