[R] different colors for two wireframe spheres
David Schellenberger Costa
david.schellenberger.costa at uni-oldenburg.de
Tue Mar 5 12:28:04 CET 2013
Dear List,
I have the code below adapted from the lattice-package examples to draw two spheres. I would now like to give
both different surface colors, e.g. one red and one blue.
## 3-D surface parametrized on a 2-D grid
n <- 10
tx <- matrix(seq(-pi, pi, length.out = 2*n), 2*n, n)
ty <- matrix(seq(-pi, pi, length.out = n) / 2, 2*n, n, byrow = T)
xx <- cos(tx) * cos(ty)
yy <- sin(tx) * cos(ty)
zz <- sin(ty)
zzz <- zz
bxx <- xx+5
byy <- yy+5
bzzz <- zzz+5
xx=rbind(xx,rep(NA,n),bxx)
yy=rbind(yy,rep(NA,n),byy)
zzz=rbind(zzz,rep(NA,n),bzzz)
gr<-rbind(matrix(1,n,2*n),rep(NA,n),matrix(2,n,2*n))
wireframe(zzz ~ xx + yy, groups=gr,col.groups=c("red","blue"))
I tried various parameters as col.groups, col.regions but I have the impression that the "groups" argument in the wireframe command can only be used when supplying a data argument, which does not allow to plot the spheres as far as I tried. Is there a solution for this?
Cheers
David Schellenberger
More information about the R-help
mailing list