This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Add Labels To Groups In Plot3D

Hi,

I am doing a 3d pca in R and would like to add the names of the groups to the image.

popn <- round(pca$x[,1])
colour <- popn - min(popn) + 1
pc <- princomp(NormalisedResult)
plot3d(pca$x[,1:3], col=colour, size=5.0)

this is how I create the plot.

When I am using the text3d command to add some text it fails.

text3d=(texts=fileName,col="blue")
Error: unexpected ',' in "text3d=(texts=fileName,"

doing it w.o. the col option give no error, but I can't see any text on the image.

Is there a way of adding the column names to the plot?

Thanks Assa

plot

Please tell us how this is related to bioinformatics?

why do you think that principal component analysis is not related to bioinformatics?

Please read the help page for text3d. What you have pasted into your question does not make any sense given what is described in the help page.

1 answer

ok,

I solved the problem by adding the coordinates like this:

  text3d(pca$x[,1], pca$x[,2], pca$x[,3], text=fileName,adj = 0.1, 
     color=setRamp(6), family="serif", font=5, cex=1)

@Sean - thanks for the comment

No problem. The R help pages are quite variable in their usefulness, but they can be helpful when things do not work as expected. I'm glad you got it worked out. As an aside, remember that you can accept your own answer.

Log in to answer this question.