kwright@eskimo.com
2004-Oct-07 15:01 UTC
[R] How to use alpha transparency channel for colors?
The release notes for R 2.0.0 states: It is now possible to specify colours with a full alpha transparency channel via the new 'alpha' argument to the rgb() and hsv() functions, or as a string of the form "#RRGGBBAA". NOTE: most devices draw nothing if a colour is not opaque, but PDF and Quartz devices will render semitransparent colours. A new argument 'alpha' to the function col2rgb() provides the ability to return the alpha component of colours (as well as the red, green, and blue components). I'm using R 2.0.0 on Windows 2000 and wanted to try this feature. The following simple test works fine: pdf("c:/alpha.pdf") plot(rnorm(1:100),rnorm(1:100),col="#000055ff",pch=16) dev.off() But as soon as I change alpha value from "ff" to "fe", the points are no longer visible for me. I've tried viewing the pdf with Acrobat Reader 5.1.0 and gsview4.5. Do I need a more recent pdf viewer? Is this feature not working on Windows? Am I doing something wrong? Any tips would be appreciated. Thanks, Kevin Wright
Deepayan Sarkar
2004-Oct-07 15:52 UTC
[R] How to use alpha transparency channel for colors?
On Thursday 07 October 2004 10:01, kwright at eskimo.com wrote:> The release notes for R 2.0.0 states: > > It is now possible to specify colours with a full alpha > transparency channel via the new 'alpha' argument to the > rgb() and hsv() functions, or as a string of the form "#RRGGBBAA". > > NOTE: most devices draw nothing if a colour is not opaque, > but PDF and Quartz devices will render semitransparent colours. > > A new argument 'alpha' to the function col2rgb() > provides the ability to return the alpha component of > colours (as well as the red, green, and blue components). > > I'm using R 2.0.0 on Windows 2000 and wanted to try this feature. > The following simple test works fine: > > pdf("c:/alpha.pdf")You probably just need (see ?pdf) pdf("c:/alpha.pdf", version = "1.4")> plot(rnorm(1:100),rnorm(1:100),col="#000055ff",pch=16) > dev.off() > > But as soon as I change alpha value from "ff" to "fe", the points are > no longer visible for me. I've tried viewing the pdf with Acrobat > Reader 5.1.0 and gsview4.5. > > Do I need a more recent pdf viewer? Is this feature not working on > Windows? Am I doing something wrong? Any tips would be appreciated. > > Thanks, > > Kevin Wright
Prof Brian Ripley
2004-Oct-07 16:08 UTC
[R] How to use alpha transparency channel for colors?
On Thu, 7 Oct 2004 kwright at eskimo.com wrote:> The release notes for R 2.0.0 states:Would that be the NEWS file? R does not have `release notes' per se.> It is now possible to specify colours with a full alpha > transparency channel via the new 'alpha' argument to the > rgb() and hsv() functions, or as a string of the form "#RRGGBBAA". > > NOTE: most devices draw nothing if a colour is not opaque, > but PDF and Quartz devices will render semitransparent colours. > > A new argument 'alpha' to the function col2rgb() > provides the ability to return the alpha component of > colours (as well as the red, green, and blue components). > > I'm using R 2.0.0 on Windows 2000 and wanted to try this feature. The > following simple test works fine: > > pdf("c:/alpha.pdf") > plot(rnorm(1:100),rnorm(1:100),col="#000055ff",pch=16) > dev.off() > > But as soon as I change alpha value from "ff" to "fe", the points are no > longer visible for me. I've tried viewing the pdf with Acrobat Reader > 5.1.0 and gsview4.5. > > Do I need a more recent pdf viewer? Is this feature not working on > Windows? Am I doing something wrong? Any tips would be appreciated.As so often happens, the `something wrong' is not reading the help file. As the NEWS file _also_ says o A 'version' argument has been added to pdf() device. If this is set to "1.4", the device will support transparent colours. pdf("alpha.pdf", version="1.4") should work for you: it does for me. -- 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
There happens to be a nice article about this by Paul Murrell in the most recent R Newsletter at http://cran.r-project.org/doc/Rnews/. -roger kwright at eskimo.com wrote:> The release notes for R 2.0.0 states: > > It is now possible to specify colours with a full alpha > transparency channel via the new 'alpha' argument to the > rgb() and hsv() functions, or as a string of the form "#RRGGBBAA". > > NOTE: most devices draw nothing if a colour is not opaque, > but PDF and Quartz devices will render semitransparent colours. > > A new argument 'alpha' to the function col2rgb() > provides the ability to return the alpha component of > colours (as well as the red, green, and blue components). > > I'm using R 2.0.0 on Windows 2000 and wanted to try this feature. The > following simple test works fine: > > pdf("c:/alpha.pdf") > plot(rnorm(1:100),rnorm(1:100),col="#000055ff",pch=16) > dev.off() > > But as soon as I change alpha value from "ff" to "fe", the points are no > longer visible for me. I've tried viewing the pdf with Acrobat Reader > 5.1.0 and gsview4.5. > > Do I need a more recent pdf viewer? Is this feature not working on > Windows? Am I doing something wrong? Any tips would be appreciated. > > Thanks, > > Kevin Wright > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >