Transparency with polygon command
You can use The function rgb()
to specify a color with an alpha transparency.
for example :
xx <- c(1:50)
yy <- rnorm(50)
n <- 50
hline <- 0
plot (yy ~ xx, type="n", axes=FALSE, ann=FALSE)
text(x=xx,y=min(yy)+max(yy),labels='a')
polygon(c(xx[1], xx, xx[n]), c(min(yy), yy, min(yy)),
col=rgb(1, 0, 0,0.5), border=NA)
Another convenient possibility for making a lighter/more-transparent version of an existing color is to use adjustcolor()
, something like
adjustcolor("red", alpha.f=0.5)