Re: [Rd] inconsistent matplot behaviour?

From: Martin Maechler <>
Date: Fri 30 Jun 2006 - 15:32:21 GMT

>>>>> "Joerg" == Joerg van den Hoff <> >>>>> on Thu, 29 Jun 2006 14:29:26 +0200 writes:

    Joerg> I raised this question quite some time ago but it quitly went down the 
    Joerg> river. I'll give it a second try (before keeping my modified version of 
    Joerg> matplot for ever...):

    Joerg> matplot supports vectors (and/or character strings) for a number of 
    Joerg> arguments namely `type', `lty', `lwd', `pch', `col', `cex'. all of them 
    Joerg> act consistently in such a way that the first entries are used for plot     Joerg> of x-column 1 vs. y-column 1 and so forth.

    Joerg> for some reason `bg' is missing from this list (maybe simplyh     Joerg> forgotten?).

It maybe that matplot() predates the "color fillable" symbols, or then the author of R's version of matplot just forgot...

    Joerg> forgotten?). this causes an, according to my mind, at least, undesirable     Joerg> (inconsistent) behaviour in calls like

    Joerg> matplot(x, y, type = 'b', pch = 21:23, col = 2:4, bg = 2:4)

    Joerg> (assuming x, y are 3-column matrices)

    Joerg> `col', `pch' and the other explicit arguments are interpreted on a 'per 
    Joerg> plot' basis whereas `bg' is transferred to plot.default and is therefore 
    Joerg> interpreted on a 'per point' basis. thus, `col' above sets the colors of 
    Joerg> the plotting symbols in the different line plots (say, column 1 to 3) 
    Joerg> whereas `bg' sets the colors alternating down each column of the data, 
    Joerg> i.e. within each  line plot.

    Joerg> question: would'nt it be desirable and more consistent/intuitive if `bg' 
    Joerg> where treated on the same footing as the other explicit parameters,     Joerg> especially if combinations of `pch>=21' and `bg' are envisaged?

    Joerg> necessary changes to matplot are trivial:

Hmm: Your patch is *not* against matplot.R from the R sources, hence is not directly applicable at all.

Also, it does need patches for the help file.

But, the R-devel (aka 2.4.0-to-be) will have the desired feature as from tomorrow.

Thank you for the suggestion,
Martin Maechler, ETH Zurich

    Joerg> 3c3
    Joerg> <     ..., add = FALSE, verbose = getOption("verbose"))
    Joerg> ---

>> bg = NULL, ..., add = FALSE, verbose = getOption("verbose"))
    Joerg> 75a76,77
>> if (length(bg) < k)
>> bg <- rep(bg, length.out = k)
    Joerg> 81c83,84
    Joerg> <             pch = pch[1], col = col[1], cex = cex[1], ...)
    Joerg> ---

>> pch = pch[1], col = col[1], cex = cex[1], bg = bg[1],
>> ...)
    Joerg> 85c88
    Joerg> <             pch = pch[i], col = col[i], cex = cex[i])
    Joerg> ---

>> pch = pch[i], col = col[i], cex = cex[i], bg = bg[i])
    Joerg> ______________________________________________
    Joerg> mailing list     Joerg> mailing list Received on Sat Jul 01 01:54:33 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 30 Jun 2006 - 18:26:08 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.