legend() buglet 2

Paul Gilbert pgilbert@bank-banque-canada.ca
Tue, 15 Dec 1998 12:45:53 -0500

Perhaps this is not a bug but rather my misunderstanding of lty and col. I would
like to
generate a legend for plots as follows:

par(mfcol = c(2, 1), mar = c(5.1, 6.1, 4.1,  2.1))
matplot(t(matrix(1:8,8,20)), type="l")
par(mfg = c(2, 1, 2, 1))
box(col = 0) #  Rbug workaround. Thanks Martin
legend((par()$usr)[1:2], (par()$usr)[3:4], as.character(1:8),
        lty=1:8, col=1:8, bty="y")

The lines for 7 and 8 do not appear in the legend.  If I do

matplot(t(matrix(1:8,8,20)), type="l", lty=1:8, col=1:8)

they do not appear in the graph. These appear to correspond to recycling of col
for lty. I've tried a few variations on this which all mismatch the lines or
colours. Is this a bug or how do I get the legend to match the plot?

Paul Gilbert

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