You can remove the legend names, assuming there are none that are also plot names, like this (untested):
args <- list(...) legnams <- intersect(names(args), names(formals(legend))] do.call("plot", replace(args, legnams, NULL)) On 3/2/06, Dimitris Rizopoulos <[EMAIL PROTECTED]> wrote: > 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 > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel