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: [EMAIL PROTECTED]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to