Frame: legends with multiple surfaces and transparency

The following code displays 3 colored planes using the lattice wireframe function. However, I cannot understand why the legend does not change by setting groups of colors. I tried to do this manually, but I just changed the color of the text. By the way, does anyone know how to make a surface 70% transparent?

library(lattice) library(akima) SurfaceData <- data.frame( x=rep(seq(0,100,length.out=10),each=10,times=3), y=rep(rep(seq(0,100,length.out=10),times=10),times=3), z=c(rep(25,100),seq(30,70,length.out=100),seq(95,75,length.out=100)), type=factor(rep(c("A","B","C"),each=100)) ) wireframe(z~x*y,data=SurfaceData,group=type, col.groups=c("red","green","blue"), scales = list(arrows=FALSE, col="black",font=10), xlab = list("Variable X",rot=30), ylab = list("Variable Y",rot=-30), zlab = list("Variable Z",rot=90), zlim = c(0,100), #auto.key=TRUE, auto.key=list(text=c("A","B","C"),col=c("red","green","blue"),lines=TRUE), par.settings = list(axis.line = list(col = "transparent")), ) 

Result:

enter image description here

Thanks!

+4
source share
2 answers

To change the color of the lines, you must replace auto.key with key and specify a list of values โ€‹โ€‹for texts and lines.

 wireframe(z~x*y,data=SurfaceData,group=type, col.groups=c("red","green","blue"), scales = list(arrows=FALSE, col="black",font=10), xlab = list("Variable X",rot=30), ylab = list("Variable Y",rot=-30), zlab = list("Variable Z",rot=90), zlim = c(0,100), key=list(text=list(c("A","B","C"),col=c("red","green","blue")), lines=list(lty=c(1,1,1),col=c("red","green","blue"))), par.settings = list(axis.line = list(col = "transparent")), ) 

To make transparent colors, you can use the rgb() function. Here I define a new variable mycolors.trans , which contains transparent colors and mycolors with the same colors but not transparent for legend entries.

 mycolors.trans = rgb(c(255,0,0), c(0,255,0), c(0,0,255),alpha = 70,maxColorValue = 255) mycolors = rgb(c(255,0,0), c(0,255,0), c(0,0,255),maxColorValue = 255) wireframe(z~x*y,data=SurfaceData,group=type, col.groups=mycolors.trans, scales = list(arrows=FALSE, col="black",font=10), xlab = list("Variable X",rot=30), ylab = list("Variable Y",rot=-30), zlab = list("Variable Z",rot=90), zlim = c(0,100), #auto.key=TRUE, key=list(text=list(c("A","B","C"),col=mycolors), lines=list(lty=c(1,1,1),col=mycolors)), par.settings = list(axis.line = list(col = "transparent")), ) 

enter image description here

+6
source

cm.? simpleTheme , for the transparency part

  par.settings = simpleTheme(alpha = 0.7) 
+1
source

All Articles