[R] Color of points in legend() ignored if plotting to PNG

Boris Steipe boris.steipe at utoronto.ca
Sun Feb 28 15:45:09 CET 2016


Works for me on Mac OS...

R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.9.5 (Mavericks)
[...]



On Feb 28, 2016, at 8:02 AM, Helmut Schuetz <helmut.schuetz at bebac.at> wrote:

> Dear all,
> 
> if I plot to a PNG, the color of filled points (pch 21:25) in legend() is ignored (i.e., only the background color is used). It does not matter whether I specify the default png(bg="white") or png(bg="transparent").
> 
> The example below
> 
> x <- rnorm(10)
> y <- rnorm(10)
> plot(x, y, pch = 21, cex = 1.5,
>  xlim = range(x, y) * 1.2, ylim = range(x, y)*1.2,
>  col = "black", bg = "lightgrey")
> legend("topleft", legend = "foo", inset = 0.02,
>  bg = "white", pch = 21, pt.cex = 1.5,
>  col = "black", pt.bg = "lightgrey")
> 
> works as desired on windows(...) but fails to show the color in the legend on png(...).
> 
> Any suggestions?
> Helmut
> 
> Environment: x86_64-w64-mingw32/x64 (64-bit), R 3.2.3
> 
> -- 
> Ing. Helmut Schuetz
> BEBAC - Consultancy Services for
> Bioequivalence and Bioavailability Studies
> Neubaugasse 36/11
> 1070 Vienna, Austria
> VAT No  ATU61115625
> DUNS    300370568
> tel     +43 1 2311746
> mobile  +43 699 10792458
> e-mail  helmut.schuetz at bebac.at
> web     http://bebac.at/
> contact http://bebac.at/Contact.htm
> forum   http://forum.bebac.at/
> 
> This e-mail is confidential and may also be legally privileged. If you
> are not the intended recipient please reply to sender, do not disclose
> its contents to any person and delete the e-mail. Any unauthorized
> review, use, disclosure, copying or distribution is strictly prohibited.
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list