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

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Mon 20 Feb 2006 - 23:01:22 EST

On 2/20/2006 5:43 AM, Laura Quinn wrote:
> 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?

A couple below, but you'll need to simplify your examples to get direct answers to your questions.
>
> g.pca <- prcomp(RtG , retx = TRUE)
> scale <- 0.4
> bg3d("black")
> amp <- 6
> zlim <- amp*range(z)

We can't execute this code, because we don't have 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) {

This doesn't look right. You're using i for two different purposes here.

Duncan Murdoch

> 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



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 23:06:03 2006

This archive was generated by hypermail 2.1.8 : Tue 21 Feb 2006 - 14:38:21 EST