s-news
[Top] [All Lists]

Re: key and margins problem when using xyplot

To: Samer Mouksassi <smouksassi@Pharsight.com>
Subject: Re: key and margins problem when using xyplot
From: Sebastien Bihorel <Sebastien.Bihorel@cognigencorp.com>
Date: Wed, 17 Dec 2008 17:36:35 -0500
Cc: Sebastien Bihorel <Sebastien.Bihorel@cognigencorp.com>, s-news@lists.biostat.wustl.edu
In-reply-to: <5B833E900330354F9FDA984D06F92428053B8A17@ca-exchange.corp.pharsight.com>
References: <49496A25.8000206@cognigencorp.com> <49496B1D.2090303@cognigencorp.com> <5B833E900330354F9FDA984D06F92428053B8A17@ca-exchange.corp.pharsight.com>
User-agent: Thunderbird 2.0.0.9 (Windows/20071031)
Hi Samer,

Thank for your reply. Unfortunately, the oma argument only changes the sizes of the plot area on the page and the key remains on top of the X-axis title... it basically does a homothetic transformation of the plot. As suggested, I might end up setting the space argument to "top".

Thanks,

Sebastien Bihorel, PharmD, PhD
PKPD Scientist
Cognigen Corp
Email: sebastien.bihorel@cognigencorp.com
Phone: (716) 633-3463 ext. 323


Samer Mouksassi wrote:

Hello Sebastien,

 

 

par(oma=c(3,6,1,2),xpd=T) # xpd to be able to plot outside the plot region and oma to change the                       #                   spaces of the margins

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", x=0.5,y=-0.2,

       transparent = T,

       text=list(c("b", "c")),

       lines = list(pch = c(16,3), type = c("p", "p"))),

     )

You can have it on the “top” side without any overlap.

 

Hope this helps,

 

Thank you,

 

Samer


From: s-news-owner@lists.biostat.wustl.edu [mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of Sebastien Bihorel
Sent: 2008-12-17 16:12
To: s-news@lists.biostat.wustl.edu
Subject: Re: [S] key and margins problem when using xyplot

 

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>