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

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Mar 2 14:16:21 CET 2006


See e.g. graphics:::plot.POSIXct, which contains

     axisInt <- function(x, type, main, sub, xlab, ylab, col,
         lty, lwd, xlim, ylim, bg, pch, log, asp, axes, frame.plot,
         ...) axis.POSIXct(1, x, ...)

You could use such as wrapper for legend, in your case probably to pick 
out just the arguments you want.


On Thu, 2 Mar 2006, Dimitris Rizopoulos 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 at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list