필터 지우기
필터 지우기

Why scatterplot shows one point in different color and rest all the points are different?

조회 수: 2 (최근 30일)
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.

답변 (1개)

the cyclist
the cyclist 2022년 9월 12일
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

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by