I've done a lot of experimenting with indexing and it looks like the indexed subset of data is always rescaled (doesn't plot to the same positions as the original (gray) data UNLESS I index some value to the end. For instance score(4630:end,1:2) works but score(4630:9257,1:2) moves the points. if I look at the paired numbers in each they are the same (one more for the former) so I think it must be a plotting error. Has anyone successfully indexed score data?
Indexing scores to plot pca results in biplot
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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)
2 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Dimensionality Reduction and Feature Extraction finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!