Grouping A Scatter Plot

2 vues (au cours des 30 derniers jours)
Yaser Khojah
Yaser Khojah le 22 Mar 2019
Commenté : Yaser Khojah le 22 Mar 2019
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
% 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
  2 commentaires
Adam
Adam le 22 Mar 2019
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.
Yaser Khojah
Yaser Khojah le 22 Mar 2019
I have tried to use this but it did not work. Any idea?
as
x = MaT_All(:,17);
y = MaT_All(:,18);
group = randi(MaT_All(:,9:16));
[uniqueGroups, uga, ugc] = unique(group);
colors = brewermap(length(uniqueGroups),'Set1'); %or any other way of creating the colormap
markersize = 20; %change to suit taste
figure
scatter(x(:), y(:), markersize, colors(ugc,:));

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by