From dimitris.rizopoulos at med.kuleuven.be  Thu Mar  2 13:54:09 2006
From: dimitris.rizopoulos at med.kuleuven.be (Dimitris Rizopoulos)
Date: Thu, 2 Mar 2006 13:54:09 +0100
Subject: [Rd] '...' passed to both plot() and legend()
Message-ID: <001a01c63df8$65d6d680$0540210a@www.domain>

Dear R-devels,

I'd like to create a plot method for a class of objects that passes 
the '...' argument to both plot() and legend(), e.g.,

x <- list(data = rnorm(1000))
class(x) <- "foo"
plot.foo <- function(x, legend = FALSE, cx = "topright", cy = NULL, 
...){
    dx <- sort(x$data)
    plot(dx, dnorm(dx), type = "l", ...)
    if (legend)
        legend(cx, cy, "Gaussian density", bty = "n", ...)
    invisible()
}
#####################
plot(x)
plot(x, legend = TRUE, cex = 1.1)


However, and as expected, if I use an argument of plot() that is not 
an argument of legend() an error occurs, e.g.,

plot(x, legend = TRUE, cex.lab = 1.1)


Is there any (efficient and appropriate) way that I could use the 
'...' argument in this case?

> version
         _
platform i386-pc-mingw32
arch     i386
os       mingw32
system   i386, mingw32
status
major    2
minor    2.1
year     2005
month    12
day      20
svn rev  36812
language R


Thanks in advance for any hints,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://www.med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



[Rd] '...' passed to both plot() and legend()
Dimitris Rizopoulos