Bug 17288 - legend(..., fill = *) stopped showing colors ca. 12 years ago
Summary: legend(..., fill = *) stopped showing colors ca. 12 years ago
Alias: None
Product: R
Classification: Unclassified
Component: Graphics (show other bugs)
Version: 3.4.0
Hardware: Other Linux
: P5 enhancement
Assignee: R-core
Depends on:
Reported: 2017-06-16 08:49 UTC by Martin Maechler
Modified: 2017-06-27 10:14 UTC (History)
1 user (show)

See Also:

R 2.0.1 version graphik _with_ colors (3.15 KB, application/pdf)
2017-06-16 08:49 UTC, Martin Maechler
R 2.4.1 graphic withOUT colors, i.e. buggy (2.77 KB, application/pdf)
2017-06-16 08:50 UTC, Martin Maechler

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Maechler 2017-06-16 08:49:45 UTC
Created attachment 2262 [details]
R 2.0.1 version graphik _with_ colors

If you look at the last example on the  ? rect  help page,
or if you just run  
    example(rect, ask=FALSE)

and carefully look at the plot, you are (hopefully) puzzled to notice that the legend "boxes" are all in black instead of using colors, notably "green".
From the old versions of R that I have installed and still working,
I find that colrs still works in  R version 2.0.1 (2004-11-15)
but are in B/W already in         R version 2.4.1 (2006-12-18) 

It is amazing to notice we introduced a bug ca. 12 years ago but it was never reported.

## a short version just focusing the bug
p.leg <- function() {
    plot(1, type="n", axes=FALSE, ann=FALSE)
    legend(0.8, 1.4, paste("legend text",1:4), cex = 2,
           fill = c(NA, "tomato", "red", "blue"),
           density = c(NA, NA, 10, 30), angle = c(NA, NA, 30, -30))


## Different useful pdfs for _different_ R versions:
Rver <- with(R.version, paste(major,minor, sep="."))
(pfile <- paste("legend-fill_",Rver,".pdf", sep=""))
pdf(pfile) ; p.leg() ; dev.off()
system(paste("evince", pfile)) # viw pdf; e.g. on Linux
Comment 1 Martin Maechler 2017-06-16 08:50:36 UTC
Created attachment 2263 [details]
R 2.4.1 graphic withOUT colors, i.e. buggy
Comment 2 Paul Murrell 2017-06-19 00:37:43 UTC
fixed in r-devel (r72808)

Retained behaviour that fill=NA gets converted to fill=par(fg)