Hi All,
I have made a 3D PCA plot using scatterplot3d in R. I want to make the data points look like spheres so it looks like the data has 3D structure. I'm fairly new to R so still learning the best ways to use R. I saw that rgl.spheres command can do this, but I'm having trouble incorporating this in my script to make it work. What is the easiest way to make this happen?
The script I'm currently using that gives me a 3D PCA plot with normal 2D looking data points is:
color=c('black','black','black','blue','blue','blue',
'red','red','red','green','green','green')
scatterplot3d(data.PC$x[,1:3], pch=19, color=color, cex.symbols=1.5, angle = 40,
box = FALSE, type='h')
Any help will be much appreciate!!
Thanks,
Afshin
I am still confused about why you would do a 3D plot of a PCA, but in any case this has been asked before: R package used for PCA plotting in a paper (rice RNA-Seq)
Mmmhh... Why are you confused? Conceptually plotting 3 components is the same as plotting 2 (or 1). I guess most PCA plots show the first 2 components only because A) 2D plots look good on paper and most of the information is anyway in the 1st and 2nd PC B) 3D plots are usually tricky to visualize on 2D devices.