[R] Labelling individual points on 3D PCA scatterplot

trz rzeszut at mcmaster.ca
Wed Oct 28 16:21:14 CET 2009


Hi There,
I'm attempting to plot 10 values on a three-dimensional PCA with text labels
next to each point. While i have no trouble doing this on 2D plots using the
'text' or 'textxy' function, I cannot find a function to do this on a 3D
plot.

I am using princomp for my PCA:

>PCA<-princomp(eucdata, cor=TRUE)
>PCA$scores [,1:3]    # the three principal components i want to plot

Then i am using 'scatterplot3d' to plot my first 3 principal components:

>scatterplot3d(PCA$scores [,1:3],xlab="Component 1 (26.9%)",main="My 3D
PCA",ylab="Component 2 
+     (17.9%)", zlab="Component 3
(12.4%)",type="h",box=FALSE,pch=21,bg=color)


And i get this:

http://www.nabble.com/file/p26096592/myPCA.jpeg 

'text' and 'textxy' only accept 2D coordinates so they do not label my
points in a way that makes sense.
I'm open to other 3D plotting functions in R, i just think this one is easy
to visually understand. In addition, If there is any way to move the grid up
to z=0 please let me know. To be clear i am trying to make my PCA look more
like this one i found in a journal article (Trejaut et al., 2005):

http://www.nabble.com/file/p26096592/journal.pbio.0030247.g003.png 

Thanks in advance!
Tom


-- 
View this message in context: http://www.nabble.com/Labelling-individual-points-on-3D-PCA-scatterplot-tp26096592p26096592.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list