1. Use the x, y and corner components to the key= list to specify
    the legend position, and
2. pass the panel.number in the panel function and test that as shown
    in the panel function below.
    Alternately you can place the horizontal line on afterwards using
    trellis.focus/trellis.unfocus as shown below.

Read the material under key= and panel= in ?xyplot for more information
on the key and panel arguments and read ?trellis.focus for more
information on trellis.focus/trellis.unfocus.


xyplot(DV~TIME | DOSE, data=data, groups=ID, layout=c(2,1),
      
key=list(x=.1,y=.8,corner=c(0,0),border=TRUE,colums=2,text=list(c("ID1","ID2"),col=c(1,4)),
             lines=list(type="o",pch=c(1,16),lty=c(1,2), col=c(1,4)),
             layout.heights=list(key.axis.padding=15)),

      panel = function(x,y,groups,...,panel.number) {
                panel.superpose.2(x,y,groups,...,type="o",pch=c(1,16),
                lty=c(1,2), col=c(1,4), cex=0.8)
        if (panel.number == 1) panel.abline(h=0.301,col=5,lty=1,lwd=2)
   }
)


# add a red horizontal line only to panel 2, 1
    trellis.focus("panel", 2, 1, highlight = FALSE)
    panel.abline(h=0.301,col=2,lty=1,lwd=2)
    trellis.unfocus()


On 8/9/06, HKAG (Henrik Agersø) <[EMAIL PROTECTED]> wrote:
>
> Dear all
>
> I have two questions regarding trellis plots - which I hope you may be able 
> to help me with.
>
> Is it possible to place the key in a trellis plot on the panel (instead of 
> beside the panel)? This will cause the same key to be reproduced on each 
> panel. Please see the plot below - here I placed the legend below the plot. I 
> tried moving the key to the function statement, but it did not really work 
> out the way I expected.
>
> One last thing, in the plot below I placed a horizontal line on the plot, is 
> it possible to only have the horizontal line on the left panel (I remember 
> that in S it was possible to state something like "if(get("cell",fr=9)==2)" 
> in the function statement to include the line on only one of the panels)?
>
> All suggestions will highly appreciated.
>
> Br Henrik
>
>
>
> ###############################
>
> data           <- as.data.frame(cbind(rep(1:4,each=25),
>                  rep(1:2,each=50) ,rep(1:25,4),
>                  rnorm(100,0,1) ))
> names(data)   <- c("ID","DOSE","TIME","DV")
>
>
>
> xyplot(DV~TIME | DOSE, data=data, groups=ID, layout=c(2,1),
>
>       
> key=list(space="bottom",border=TRUE,colums=2,text=list(c("ID1","ID2"),col=c(1,4)),
>              lines=list(type="o",pch=c(1,16),lty=c(1,2), col=c(1,4)),
>              layout.heights=list(key.axis.padding=15)),
>
>       panel = function(x,y,groups,...) {
>                 panel.superpose.2(x,y,groups,...,type="o",pch=c(1,16),
>                 lty=c(1,2), col=c(1,4), cex=0.8)
>                 panel.abline(h=0.301,col=5,lty=1,lwd=2)
>    }
> )
>
> ###############################
>
>
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>

______________________________________________
R-help@stat.math.ethz.ch 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.

Reply via email to