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:43:40 -0500
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <5B833E900330354F9FDA984D06F92428053B8A37@ca-exchange.corp.pharsight.com>
References: <49496A25.8000206@cognigencorp.com> <49496B1D.2090303@cognigencorp.com> <5B833E900330354F9FDA984D06F92428053B8A17@ca-exchange.corp.pharsight.com> <49497EF3.5040502@cognigencorp.com> <5B833E900330354F9FDA984D06F92428053B8A37@ca-exchange.corp.pharsight.com>
User-agent: Thunderbird 2.0.0.9 (Windows/20071031)
Well, the nice thing about the space argument is that it centers the legend on the page. By using x and y, I would have to figure out the best values to do this centering. Since I want to use this code on a variety of situation (meaning different legend texts), I would have to find a way to determine the "physical" size of my legend to adjust x and y. Any suggestion for doing that?

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


Samer Mouksassi wrote:

Dear Sebastien,

 

You can add an x and y argument for your key command  so you can change its place.

 

Samer

 

 

 

 

Samer Mouksassi, Pharm.D.

Associate (PK Scientist)
smouksassi@Pharsight.com


 

Pharsight Corporation
(http://pharsight.com/main.php)

Reporting and Analysis Services (RAS)
(http://pharsight.com/services/ras_home.php)

2000 Peel Street, Suite 570

Montreal, Quebec

H3A 2W5 CANADA

Land: (514) 789-2184

Fax:  (514) 789-2192
Cell:  (514) 475-9339

 


From: Sebastien Bihorel [mailto:Sebastien.Bihorel@cognigencorp.com]
Sent: 2008-12-17 17:37
To: Samer Mouksassi
Cc: Sebastien Bihorel; s-news@lists.biostat.wustl.edu
Subject: Re: [S] key and margins problem when using xyplot

 

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>