[Rd] inconsistent matplot behaviour?

Joerg van den Hoff j.van_den_hoff at fz-rossendorf.de
Thu Jun 29 14:29:26 CEST 2006


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

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

for some reason `bg' is missing from this list (maybe simplyh 
forgotten?). this causes an, according to my mind, at least, undesirable 
(inconsistent) behaviour in calls like

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

(assuming x, y are 3-column matrices)

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

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

necessary changes to matplot are trivial:

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



More information about the R-devel mailing list