Dear R graphics experts, Do you know of any way of plotting semi-transparent points in R ? I face this problem any time I want to e.g. plot thousands of points that belong to two or three classes which I color code. With the default opaque colors, the plotting order matters and basically the points I plot last completely dominate the picture. I would much rather have the overlaying points mix in color.. Thanks a lot, Markus
See ?rgb and its alpha argument, for example. Uwe Ligges Markus Loecher wrote:> Dear R graphics experts, > Do you know of any way of plotting semi-transparent points in R ? > I face this problem any time I want to e.g. plot thousands of points > that belong to two or three classes which I color code. > With the default opaque colors, the plotting order matters and > basically the points I plot last completely dominate the picture. I > would much rather have the overlaying points mix in color.. > > Thanks a lot, > Markus > > ______________________________________________ > R-help at r-project.org mailing list > 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.
See ?rgb and the article by Paul Murrell in R-news 2004-2. (The details of where it is supported have changed in the last three years, though.) On Wed, 10 Oct 2007, Markus Loecher wrote:> Dear R graphics experts, > Do you know of any way of plotting semi-transparent points in R ? > I face this problem any time I want to e.g. plot thousands of points > that belong to two or three classes which I color code. > With the default opaque colors, the plotting order matters and > basically the points I plot last completely dominate the picture. I > would much rather have the overlaying points mix in color.. > > Thanks a lot, > Markus-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
It can be as simple as:> plot( rnorm(1000), rnorm(1000), col="#0000ff22", pch=16,cex=3)Where the color is "#RRGGBBAA" and the AA portion is the opacity/trasparency. Of course this only works if you are using a graphics device that supports transparency. The windows device under R 2.6.0 does (but not any previous versions), the Cairo device does, the PDF device does (as long as you set the correct options), and I think the default device on Macs does, I don't know which others do. The rgl package has another way of doing this (but may be overkill for your approach). If you are interested in plotting lots of points, look at the hexbin package (bioconductor I think) for an alternative way of presenting the data. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at intermountainmail.org (801) 408-8111> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of Markus Loecher > Sent: Wednesday, October 10, 2007 9:48 AM > To: r-help at stat.math.ethz.ch > Subject: [R] transparent colors > > Dear R graphics experts, > Do you know of any way of plotting semi-transparent points in R ? > I face this problem any time I want to e.g. plot thousands of > points that belong to two or three classes which I color code. > With the default opaque colors, the plotting order matters > and basically the points I plot last completely dominate the > picture. I would much rather have the overlaying points mix in color.. > > Thanks a lot, > Markus > > ______________________________________________ > R-help at r-project.org mailing list > 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. >