[Rd] Transparency convenience function

Byron Ellis byron.ellis at gmail.com
Tue Feb 6 22:32:29 CET 2007


Hi all,

For making plots with transparency I've found the following function
quite useful when specifying colors that I thought might be of
interest (I suspect it's easier to implement under R-devel. IIRC rgb()
now takes matrix arguments):

alpha <- function(colors,alpha=1.0) {
	if(alpha < 0 || alpha > 1)
		stop("alpha must be in [0,1]")
	apply(col2rgb(colors)/255,2,function(x) rgb(x[1],x[2],x[3],alpha))
}

-- 
Byron Ellis (byron.ellis at gmail.com)
"Oook" -- The Librarian



More information about the R-devel mailing list