Why scatterplot shows one point in different color and rest all the points are different?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I've made a scatterplot as shown below. As it's clearly seen that one point in the scatterplot is of purple color. I can't fgure out why its like this. If I remove this point from my data, the values in the next row are shown in purple. If I remove this row also, it then moves to the next row. Why it is like this. Here is my code for this scatterplot.
Data=readtable('E:\Table\Data11.xlsx', 'Sheet', 1, 'ReadVariableNames', true, 'VariableNamingRule','preserve');
Data.Aerosols=1E9*Data.Aerosols;
Data.Volume_Bin=discretize(Data.Volume,[500,900]); %first bin (0-500), second bin is (500-900)
Data.BTemp_Bin = discretize(Data.B_Temp,[0,10]); %first bin (0-10), second bin (10-20)
figure
hAx=axes; hold on
hL=splitapply(@plotrows,Data.Aerosols,Data.G_Temp, Data.Volume_Bin);
hold on
hL=splitapply(@plotrows,Data.Aerosols,Data.G_Temp, Data.BTemp_Bin);
hAx.XScale='log';
grid on
set(gca, 'YDir', 'reverse');
xlabel('Aerosols concentration', 'Fontweight', 'bold')
ylabel('GTemp', 'Fontweight', 'bold')
legend({'Volume [500-900J/kg]','B_Temp [0-10]'},'Location','southeast')
%%%%%%%%%%%%%%%%%%%%% plotrows function %%%%%%%%%%%%5
function hL=plotrows(x,y,varargin)
xy=sortrows([x y]);
hL=scatter(xy(:,1),xy(:,2),varargin{:},'filled');
end
What is causing this issue and how can I solve it? I'll be grateful for any help.
P.S. I have also attached the data.
0 commentaires
Réponses (1)
the cyclist
le 12 Sep 2022
If I have interpreted your code correctly, you have plotted the x-y data, just in different groups. Your figure actually has four distinct plots on it, because each call to splitapply plots two groups. But because it is the same x-y data, the points are mostly over-striking each other, so you don't see them. By adding a couple more entries to the legend, you can see this.
Data=readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1122740/Data11.xlsx', 'Sheet', 1, 'ReadVariableNames', true, 'VariableNamingRule','preserve');
Data.Aerosols=1E9*Data.Aerosols;
Data.Volume_Bin=discretize(Data.Volume,[500,900]); %first bin (0-500), second bin is (500-900)
Data.BTemp_Bin = discretize(Data.B_Temp,[0,10]); %first bin (0-10), second bin (10-20)
figure
hAx=axes; hold on
hL=splitapply(@plotrows,Data.Aerosols,Data.G_Temp, Data.Volume_Bin);
hold on
hL=splitapply(@plotrows,Data.Aerosols,Data.G_Temp, Data.BTemp_Bin);
hAx.XScale='log';
grid on
set(gca, 'YDir', 'reverse');
xlabel('Aerosols concentration', 'Fontweight', 'bold')
ylabel('GTemp', 'Fontweight', 'bold')
legend({'Volume [500-900J/kg]','B_Temp [0-10]','L3','L4'},'Location','southeast')
%%%%%%%%%%%%%%%%%%%%% plotrows function %%%%%%%%%%%%5
function hL=plotrows(x,y,varargin)
xy=sortrows([x y]);
hL=scatter(xy(:,1),xy(:,2),varargin{:},'filled');
end
0 commentaires
Voir également
Catégories
En savoir plus sur Lighting, Transparency, and Shading dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!