Grouping A Scatter Plot
2 次查看(过去 30 天)
显示 更早的评论
I have a big matrix (17400X18) as attached where I created their scatters by plotting column (17) vs column (18) as in Figure 1 and Code1. Now there are many dots and I'm trying to group them based on their values from column 9 to 16. I understand it is not a one dimension thing and I want to find a way to present them. So, I filter these data based on their values in column 9 to 16 as below (Code 2 and Figure 2). So, I have three questions as below:
1) Is there a way to do them automatically rather than filter them manually?
2) How can I create more colours for the scatters?
3) I have studied the impact of the column 9 to 16 and I have to do similar study for column 1 to 8, any idea than doing it manually?
%% Code (1)
% figure
scatter(MaT_All(:,18),MaT_All(:,17));
Figure 1
![Scatter1.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/209847/Scatter1.png)
% impact of year zero (Code 2)
idx_1_2_3 = find(MaT_All(:,9) == 0 & MaT_All(:,10) == 0 & MaT_All(:,11) == 0 &MaT_All(:,12) > 0 & MaT_All(:,13) > 0 & MaT_All(:,14) > 0 & MaT_All(:,15) > 0 & MaT_All(:,16) > 0 ); % fields 1 & 2 & 3 only
idx_1_2 = find(MaT_All(:,9) == 0 & MaT_All(:,10) == 0 & MaT_All(:,11) > 0 &MaT_All(:,12) > 0 & MaT_All(:,13) > 0 & MaT_All(:,14) > 0 & MaT_All(:,15) > 0 & MaT_All(:,16) > 0 ); % fields 1 & 2 only
idx_1_3 = find(MaT_All(:,9) == 0 & MaT_All(:,10) > 0 & MaT_All(:,11) == 0 &MaT_All(:,12) > 0 & MaT_All(:,13) > 0 & MaT_All(:,14) > 0 & MaT_All(:,15) > 0 & MaT_All(:,16) > 0 ); % fields 1 & 3 only
idx_1_8 = find(MaT_All(:,9) == 0 & MaT_All(:,10) > 0 & MaT_All(:,11) > 0 &MaT_All(:,12) > 0 & MaT_All(:,13) > 0 & MaT_All(:,14) > 0 & MaT_All(:,15) > 0 & MaT_All(:,16) == 0 ); % fields 1 & 8 only
idx_1_4 = find(MaT_All(:,9) == 0 & MaT_All(:,10) > 0 & MaT_All(:,11) > 0 &MaT_All(:,12) == 0 & MaT_All(:,13) > 0 & MaT_All(:,14) > 0 & MaT_All(:,15) > 0 & MaT_All(:,16) > 0 ); % fields 1 & 4 only
idx_1_5 = find(MaT_All(:,9) == 0 & MaT_All(:,10) > 0 & MaT_All(:,11) > 0 &MaT_All(:,12) > 0 & MaT_All(:,13) == 0 & MaT_All(:,14) > 0 & MaT_All(:,15) > 0 & MaT_All(:,16) > 0 ); % fields 1 & 5 only
idx_1_4_5 = find(MaT_All(:,9) == 0 & MaT_All(:,10) > 0 & MaT_All(:,11) > 0 &MaT_All(:,12) == 0 & MaT_All(:,13) == 0 & MaT_All(:,14) > 0 & MaT_All(:,15) > 0 & MaT_All(:,16) > 0 ); % fields 1 & 4 & 5 only
idx_1_2_4_5 = find(MaT_All(:,9) == 0 & MaT_All(:,10) == 0 & MaT_All(:,11) > 0 &MaT_All(:,12) == 0 & MaT_All(:,13) == 0 & MaT_All(:,14) > 0 & MaT_All(:,15) > 0 & MaT_All(:,16) > 0 ); % fields 1 & 2 & 4 & 5 only
% impact of starting field 1 after 5
idx_1_A_1 = find(MaT_All(:,9) > 1); % fields 1 after year 5
idx_1_A_5 = find(MaT_All(:,9) > 5); % fields 1 after year 5
figure
scatter(MaT_All(:,18),MaT_All(:,17)); hold on
scatter(MaT_All(idx_1_2_3,18),MaT_All(idx_1_2_3,17),'filled','m'); hold on % 1 2 3 only
scatter(MaT_All(idx_1_2,18),MaT_All(idx_1_2,17),'filled','y'); hold on % 1 2 only
scatter(MaT_All(idx_1_3,18),MaT_All(idx_1_3,17),'filled','r'); hold on % 1 3 only
scatter(MaT_All(idx_1_8,18),MaT_All(idx_1_8,17),'filled','o'); hold on % 1 8 only
scatter(MaT_All(idx_1_4,18),MaT_All(idx_1_4,17),'filled','k'); hold on % 1 4 only
scatter(MaT_All(idx_1_5,18),MaT_All(idx_1_5,17),'filled','m'); hold on % 1 5 only
scatter(MaT_All(idx_1_4_5,18),MaT_All(idx_1_4_5,17),'filled','r'); hold on % 1 4 5 only
scatter(MaT_All(idx_1_2_4_5,18),MaT_All(idx_1_2_4_5,17),'filled','r'); hold on % 1 2 4 5 only
scatter(MaT_All(idx_1_A_1,18),MaT_All(idx_1_A_1,17),'filled','m'); hold on % After 1
scatter(MaT_All(idx_1_A_5,18),MaT_All(idx_1_A_5,17),'filled','y'); hold on % After 5
Figure 2
![Group.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/209848/Group.png)
2 个评论
Adam
2019-3-22
You can create more colours by using [r g b] triplets for colour rather than strings like 'r', though I can't remember if you need to prepend those with 'color'. I seem to remember when I do it that it does expect that if you aren't using the string colour representation.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!