Question

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?

Was it helpful?

Solution

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). ...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top