add.alpha function
to reproduce the example...
png("transparent_poly.png", width=4, height=4, res=200, units="in") par(mar=c(4,4,1,1), ps=8) x <- seq(-180, 180,, 30) y <- seq(-90, 90,, 30) grd <- expand.grid(x=x,y=y) z <- sqrt(grd$x^2+grd$y^2) dim(z) <- c(length(x), length(y)) pal <- colorRampPalette(c(rgb(1,1,1), rgb(0,0,0))) COLORS <- pal(20) image(x,y,z, col=COLORS) z2 <- grd$x^2+grd$y dim(z2) <- c(length(x), length(y)) pal <- colorRampPalette(c(rgb(0.5,1,0), rgb(0,1,1), rgb(1,1,1))) COLORS <- add.alpha(pal(20), 0.4) image(x,y,z2, col=COLORS, add=TRUE) dev.off()
Thank you thank you thank you! I've been struggling with searching for a solution for a while,a nd this works perfectly!
ReplyDeletecheers!!