Indexing scores to plot pca results in biplot
Afficher commentaires plus anciens
I am trying to visualize the results of a principal component analysis using biplot. I want to color the data by site (or time intervals, etc). Let's take coloring the results by site as an example: In this case the first half of the data (first 4629 rows in the scores output from the pca function) is for site 1 and the second half for site 2 (rows 4630 to the end in the scores output).
When I plot all of the data in gray (circles) and the sites in colors (points), the first site (blue) doesn't line up with the gray points and I can't figure out why.
Am I indexing the score values correctly if score is a 9258x8 double and I want to plot the first 4629 rows (site 1) in blue then the second 4629 rows (site 2) in red?
X = horzcat(DO_s,O2sat_s,PH_s,Temp_s,Sal_s,Depth_s,PAR_s,absVel_s);
[coeff,score,latent,tsquared] = pca(X);
f4=figure(4)
hold on; box on;
biplot(coeff(:,1:2),'scores',score(:,1:2),'color','k','Marker','o','markeredgecolor',[.9 .9 .9])
biplot(coeff(:,1:2),'scores',score(1:4629,1:2),'color','k','Marker','.','markeredgecolor','b','varlabels',...
{'DO','O2sat','pH','Temp','Sal','Depth','PAR','|Velocity|'}); %Site 1 (1:4629)
biplot(coeff(:,1:2),'scores',score(4630:end,1:2),'color','k','Marker','.','markeredgecolor','r') %Site 2 (4630:end)
yline(0,'--')
xline(0,'--')
title('Full Deployment');
set(gca,'fontsize',18)
Réponses (0)
Catégories
En savoir plus sur Dimensionality Reduction and Feature Extraction dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!