[Rd] plot.mts() with type="p" (PR#1010)

Kurt Hornik Kurt.Hornik@ci.tuwien.ac.at
Sun, 8 Jul 2001 10:23:06 +0200


>>>>> Achim Zeileis writes:

> Ray.Brownrigg@mcs.vuw.ac.nz wrote:
>> 
>> There appears to be a bug in plot.mts() in R-1.3.0 when attempting to
>> do a multiple point plot (this worked in 1.2.2).
>> 
>> > plot.mts(ts(matrix(runif(10), ncol = 2)), type = "p")
>> Error in plot.ts(x[, i], axes = FALSE, xlab = "", ylab = "", log = log,  :
>> formal argument "type" matched by multiple actual arguments

> Yes, this seems to be a bug. The reason is the new panel argument in
> plot.mts. Every single plot in plot.mts is set up by:

>         plot(x[, i], axes = FALSE, xlab="", ylab="",
>              log = log, col = col, bg = bg, pch = pch, ann = ann,
>              type="n", ...)
>         panel(x[, i], col = col, bg = bg, pch = pch, ...)

> And I suspect you don't really need to pass the ... argument to
> plot(type="n") because what you really see is what panel produces
> after that. If you remove the ... in plot the example above works. It
> also works, if both commands are replaced by a single

>         panel(x[, i], axes = FALSE, xlab="", ylab="",
>              log = log, col = col, bg = bg, pch = pch, ann = ann,
>              ...)

If this was only about plot.mts(), I'd say that the `...' are graphics
parameters and not additional arguments to the panel function, and hence
the behavior is as expected.  The desired effect can be obtained by
using `panel = points'.

Btw, we get the same for

R> data(USJudgeRatings)
R> pairs(USJudgeRatings, type = "l")
Error in plot.default(x[, j], x[, i], xlab = "", ylab = "", axes = FALSE,  : 
        formal argument "type" matched by multiple actual arguments

Ok but perhaps not too helpful.  In an ideal world, we should perhaps
match the `...' against the possible pars before passing them on.

However, I think there are more problems.

?plot.mts [why would I know to look for this anyway?  We need to do
something along the lines John suggested in Vienna: have a way to find
out about the possible args to plot() when calling it on a specific
object or class ...] says

plot(x, y = NULL, type = "l", xlim = NULL, ylim = NULL,
     xlab = "Time", ylab, log = "",
     col = par("col"), bg = NA, pch = par("pch"), cex = par("cex"),
     lty = par("lty"), lwd = par("lwd"),
     axes = TRUE, frame.plot = axes, ann = par("ann"),
     main = NULL, plot.type = c("multiple", "single"),
     xy.labels = n <= 150, xy.lines = do.lab, panel=lines, ...)

and this even has an explicit `type' argument!

Of course what happens is that what we see is the documentation for the
ts and not the mts method.

The short term fix would be to document plot.mts separately.

However, does plot.mts really need to be a function of its own with an
interface *different* from plot.ts?  We seem to be calling each other
vice versa anyway ...

-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._