[R] Further rgl()/spheres3d() query

From: Laura Quinn <laura_at_env.leeds.ac.uk>
Date: Mon 20 Feb 2006 - 21:43:32 EST


Hi,

I am applying the following code to map pca loadings onto a 3d grid, my problem is this - the output only plots the spheres in the requested color (in this case "red") for the first argument. The sphere from the second argument appear as flat dark circles. Also the text3d() command only seems to work for a couple of the positions, with no text added in most cases. Could anyone offer any suggestions?

 g.pca <- prcomp(RtG , retx = TRUE)
 scale <- 0.4
 bg3d("black")
 amp <- 6
 zlim <- amp*range(z)
 zlen <- (zlim[2] - zlim[1])*100
 colorlut <- terrain.colors(zlen) # height color lookup table  col <- colorlut[ ((z*amp)-zlim[1])*100+1 ] # assign colors to heights  surface3d(x,y,z*amp,color=col)
 for (i in 1:30) {
 for (i in 1) {
 pc <- g.pca$rotation[,i]
 pc.pos <- (pc > 0)
 if (any(pc.pos)) {
  spheres3d(xval[pc.pos],yval[pc.pos],6*zsamp[pc.pos],

     radius=scale*pc[pc.pos],color="red")
}

 if (any(!pc.pos)) {
  spheres3d(xval[!pc.pos],yval[!pc.pos],6*zsamp[!pc.pos],

     radius=scale*pc[!pc.pos],color="blue")
}

 points3d(sample[i,1],sample[i,2],sample[i,3],color="white",size=3.5,

          lit=TRUE)
 text3d(sample[i,1],sample[i,2],sample[i,3],i,adj=0)
}}

Thanks in advance,
Laura

Laura Quinn
Institute of Atmospheric Science
School of Earth and Environment
University of Leeds
Leeds
LS2 9JT

tel: +44 113 343 1596
fax: +44 113 343 6716
mail: laura@env.leeds.ac.uk



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Feb 20 21:47:27 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:36 EST