plot PCA projection: How interpret

question
package
plotting
pyplot
packages

#1

I want to perform PCA on my data_array object.
How do I get a nice plot of the data projected onto the first two principal components?

I tried

using ManifoldLearning
using Plots

M1 = fit(PCA, data_array; maxoutdim=2)
# transforms observations data_array into PCs
Y1 = transform(M1, data_array) # 2x547
X_PCA = reconstruct(M1, Y1) # 96x547
M1_proj = projection(M1) # 96x2

Plots.scatter(M1_proj, title="PCA projection", legend=false)

but I cannot quite interpret the plot… It does not look any like standard PCA projection plots.

Any ideas?


#2

you are plotting the rotation matrix, which is usually plotted as arrows in a biplot (see here for an example), you have to plot Y1 for the actual points.


#3

Thanks! I just realised it is Y1. However, how can I plot the rotation matrix, or rather the new directions in the old coordinate system ?


#4

You use the rotation matrix as coordinates for the arrow tips, all arrows start from the origin. You may have to scale them, so they fit nicely into your data.


#5

Thanks, yes, I know. That is my question. I can’t find the right package/function.


#6

For serious plotting I still use RCall, depending on where you come from you might want to consider PyPlot too.