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?