s-news
[Top] [All Lists]

Re: key and margins problem when using xyplot

To: s-news@lists.biostat.wustl.edu
Subject: Re: key and margins problem when using xyplot
From: Sebastien Bihorel <Sebastien.Bihorel@cognigencorp.com>
Date: Wed, 17 Dec 2008 16:11:57 -0500
In-reply-to: <49496A25.8000206@cognigencorp.com>
References: <49496A25.8000206@cognigencorp.com>
User-agent: Thunderbird 2.0.0.9 (Windows/20071031)
Dear S-users,

I have a hard time finding a solution to the following problem. I have this function which, among others things, creates and print a trellis plot created with xyplot. Different data.frame objects are sent to this function along with others variables. Everything would be fine if only the legend of my plot was not displayed on top of my X-axis title (see sample script below). Is there a way to increase the margin for the key, or should I specify the key differently?

Thanks in advance for your advises.

myfcn <- function(mydf){
  assign("mydf",mydf,frame=1)

   myplot<-xyplot(b~a|ID,
     data=""
     panel=function(x,y,subscripts){
       panel.xyplot(x, y, pch=16)
       panel.xyplot(mydf$a[subscripts],mydf$c[subscripts],pch=3)
       },
       as.table=T,
       subscripts=T,
       key = list(space="bottom",
        transparent = T,
        text=list(c("b", "c")),
        lines = list(pch = c(16,3), type = c("p", "p"))),
     )

   print(myplot)
}

a <- rep((1:10),times=2)
b <- rep((11:20),times=2)
c <- rep((20:11),times=2)
ID<- rep((1:4), each =5)

mydf<-data.frame(a,b,c,ID)

myfcn(mydf)
Sebastien Bihorel, PharmD, PhD
PKPD Scientist
Cognigen Corp
Email: sebastien.bihorel@cognigencorp.com
Phone: (716) 633-3463 ext. 323
<Prev in Thread] Current Thread [Next in Thread>