Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R segments can't handle transparency?

In R (3.0.2 in Windows 7) segments() function can't handle transparency?

dev.new(width=10,height=10)
par(mar=c(0,0,0,0))
x = 1:10
y = 10:1
plot(x,y)
segments(0,0,10,10,col=rgb(0,0,0,0.5))

This should draw a gray line over the plot, but nothing is drawn. Why?

like image 431
Rodrigo Avatar asked Feb 17 '14 13:02

Rodrigo


1 Answers

According to grDevices help, (?dev.capabilities)

Most recent devices support semi-transparent colours provided the graphics format does (which PostScript does not). On the other hand, relatively few graphics formats support (fully or semi-) transparent backgrounds: generally the latter is found only in PDF and PNG plots.

Which seems to be right in line with the original questions reported behaviour and the reported response to the filed bug report. (see the comments)

This is a function of how Windows' GDI handles translucency (transparency works just fine, but that colour is not transparent). ...

like image 120
Thell Avatar answered Nov 20 '22 08:11

Thell