Reputation: 1
I have trouble using transparency with RGL. I have a numeric variable ("Plague"), two binary variables ("Fortune" and "Have diamonds"). I make a regression of the two binary variables on the numeric one "plague ~ fortune + diamond".
To illustrate this, I want to draw the points in 3D, then draw the regression plan. MI want the plan to be transparent, but it is not! I tried with the alpha channel, also with adjuscolor. I get a false transparency: The color of the plan change as if it was transparent, but we can not see through. Do you know how I can get real transparency with rgl?
Here is my code
set.seed(13)
dn <- expand.grid(id=1,Fortune=c("Riche","Pauvre"),Diamant=c("Oui","Non"))
dn <- dn[rep(1:4,times=c(50,5,10,100)),]
n <- nrow(dn)
dn$id <- 1:n
dn$Plague <- round(runif(n,0,ifelse(dn$Fortune=="Riche",10,30)),1)
library(rgl)
plot3d(dn$Fortune,dn$Diamant,dn$Plague,xlim=c(0.8,2.2),ylim=c(0.8,2.2),zlim=c(0,50),
axes=TRUE,xlab="",ylab="",zlab="")
triangles3d(x=c(0.8,0.8,2.2),y=c(0.8,2.2,2.2),z=c(2,9,23),col=adjustcolor("red",0.3),alpha=0.3)
triangles3d(x=c(2.2,2.2,0.8),y=c(2.2,0.8,0.8),z=c(23,16,2),col=adjustcolor("red",0),alpha=0.3)
Thanks for your help!
Christophe
Upvotes: 0
Views: 1468
Reputation: 21
OK - I know that the question is a bit dated...
It seems... to set transparency in rgl you need to modify the 'material' in which the object is displayed. This is done through:
material3d()
So to set the transparency of color 1 (black) to 80%
material3d(1,alpha=0.2) # with alpha = 1-0.8
Upvotes: 2