Skip to content

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

3 messages · Ray Brownrigg, Achim Zeileis, Kurt Hornik

#
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).

Reproduce by:
_                   
platform sparc-sun-solaris2.8
arch     sparc               
os       solaris2.8          
system   sparc, solaris2.8   
status                       
major    1                   
minor    3.0                 
year     2001                
month    06                  
day      22                  
language R
Error in plot.ts(x[, i], axes = FALSE, xlab = "", ylab = "", log = log,  : 
        formal argument "type" matched by multiple actual arguments
3: plot.ts(x[, i], axes = FALSE, xlab = "", ylab = "", log = log, 
       col = col, bg = bg, pch = pch, ann = ann, type = "n", ...)
2: plot(x[, i], axes = FALSE, xlab = "", ylab = "", log = log, col = col, 
       bg = bg, pch = pch, ann = ann, type = "n", ...)
1: plot.mts(ts(matrix(runif(10), ncol = 2)), type = "p")
The problem is that plot.mts calls plot() with an explicit type = "n"
as well as ..., so the type argument is sent twice.

My short-term solution is to change plot.mts() so that:

    for (i in 1:nser) {
        plot(x[, i], axes = FALSE, xlab = "", ylab = "", log = log,
            col = col, bg = bg, pch = pch, ann = ann, type = "n",
            ...)
becomes:

    for (i in 1:nser) {
        plot(x[, i], axes = FALSE, xlab = "", ylab = "", log = log,
            col = 0, bg = bg, pch = pch, ann = ann, 
            ...)

Ray Brownrigg

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Ray.Brownrigg@mcs.vuw.ac.nz wrote:
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,
             ...)

Hope this helps
Achim


---------------------------
Achim Zeileis
Institut für Statistik
Technische Universität Wien
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
3 days later
#
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._