[R] labels in rgl.sphere

Dieter Menne dieter.menne at menne-biomed.de
Fri May 29 08:32:06 CEST 2009




Naoki Irie-3 wrote:
> 
> I am using rgl.sphere to visualize scatter plot data in three  dimensional
> space. However, as I can not see the labels of each data point directly in  
> RGL window, I usually look for the values of x, y, z axis to find out the
> label  (or line number of the data point).
> 
> Is there any way that I can label all the (or clicked)  data point (= 
> sphere) ?
> 

I used a function like that below to mark a point, and kept a list of id.
When the point was selected the next time, I erased and redrew it in another
color.

Dieter

# ----------------- plotDot
----------------------------------------------------
plotDot = function(data,col="black",ptsize=10,offset=30){
  # Plot a lollypop               ()
  # returns id of sphere (assuming line is id +1)
  x = data[1]
  y = data[2]
  z = data[3]
  zoff = z+offset
  # bit ball
  id = spheres3d(x,y,zoff,r=ptsize,color=col)
  # little ball at bottom
  spheres3d(x,y,z,r=3,color=col)
  apply(cbind(x,y,z,zoff),1,
    function(X) {lines3d(
      x=rep(X[1],2),
      y=rep(X[2],2), 
      z=c(X[3],X[4]),
      col="black", size=2)
        })
  id
}



-- 
View this message in context: http://www.nabble.com/labels-in-rgl.sphere-tp23773810p23774895.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list