[R] using identify() with scatterplot3d()

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Jun 27 19:59:06 CEST 2002


Tak Wing Chan wrote:
> 
> Dear all
> 
> I am running R 1.4.1 on a Linux box. I have tried to label data points
> in a 3-d scatterplot, but without much success. What I did was as
> follows:
> 
> > scatterplot3d(x, y, z)
> > identify(x, y, z, row.names(Data))
> 
> When I tried to click on/near the data points, I either receive this
> msg:
> 
> warning: no point with 0.25 inches,
> 
> or some numbers in Data, not the row names, come up on the graph. So I
> wonder if I've got something wrong. Is it possible to use identify()
> with scatterplot3d() ?

Yes, but it's tricky. Since scatterplot3d() performs a projection 3D -->
2D and identify() is designed for 2D, we have to use the following
trick:

scatterplot3d() returns invisibly some useful functions to do the
transformation for the generated plot. So let's assign the result into
"s3d":

  s3d <-  scatterplot3d(x, y, z) 
  # No we can use:
  identify(s3d$xyz.convert(x, y, z), row.names(Data))

For details see the Values section in ?scatterplot3d. 


Anyway, if you want to label *all* points, you can use:

  s3d <- scatterplot3d(x, y, z) 
  text(s3d$xyz.convert(x, y, z), label = row.names(Data), pos = 4)

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list