Kazo
Kazo

Reputation: 1255

Transparency with polygon command

I used the polygon command in R which created an area in the plot. However, the values in this area are not shown whereas the main aim is to monitor these values. Does anyone know how to handle this?

Upvotes: 26

Views: 40019

Answers (2)

Ben Bolker
Ben Bolker

Reputation: 226427

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) 

Upvotes: 14

agstudy
agstudy

Reputation: 121578

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)

enter image description here

Upvotes: 50

Related Questions