How to seperate the scattered population in three broad groups

조회 수: 1 (최근 30일)
I would appreciate your help and suggestions. Please find attached the XY plot where the (X,Y) points are broadly separated in three regions ( marked) based on some geochemical anomaly.For any set of data, I can manually separate these three regions 1) High X values with high scatter on the top (High SD) followed by 2) middle region with moderate X values less scatter (SD low) 3) Very low X values , uniform with less scatter ( very low SD). How to separated these three regions by using Matlab and put the marker lines as marked with dashed line? Regards, Sanjib

채택된 답변

Pawel Jastrzebski
Pawel Jastrzebski 2018년 4월 9일
If you want to manually decide where the partition line is, then this is more or less how you would go about recreating your Excel chart in Matlab, obviously using real data:
% Randomly generated data
x = 1:30;
y = 0.5*x;
y(1:10) = y(1:10).*rand(1,10);
y(11:20) = y(11:20)+4*rand(1,10);
y(21:30) = y(21:30)+8*rand(1,10);
% partition lines data
x1 = [min(x) max(x)]; % x-range for the partition lines
y1 = [4 4]; % dashed black line
y2 = [15 15]; % dashed red line
% main plot
figure
p(1) = plot(x,y);
hold on
p(2) = plot(x1,y1);
p(3) = plot(x1,y2);
title('Chart title')
xlabel('x-axis data')
ylabel('y-axis data')
legend({'Main data' 'partition A' 'partition B'},...
'Location','best')
% set the properties of the lines
% p(1) - main data
set(p(1),...
'LineStyle' ,'-',...
'LineWidth' ,0.5,...
'Color' , [0 0 0],...
'Marker' , '.',...
'MarkerSize' , 12,...
'MarkerFaceColor',[0 0 1],...
'MarkerEdgeColor',[0 0 1]);
% p(2) and p(3) - partition lines COMMON settigs
set([p(2), p(3)],...
'LineStyle','--',...
'LineWidth',0.5);
% p(2) - color
set(p(2),...
'Color', [0 0 0]);
set(p(3),...
'Color', [1 0 0]);
The output:

추가 답변 (1개)

Razvan Carbunescu
Razvan Carbunescu 2018년 4월 9일
편집: Razvan Carbunescu 2018년 4월 9일
In addition to the suggestion above, if you are looking for a way to automate the process of splitting the data could look at the ischange functionality added in R2018a.
% Code to find change locations
[TF,S1] = ischange(y,'MaxNumChanges',2);
plot(y,'*'); hold on; stairs(S1);
For your particular dataset it seems like a variance approach might work best to separate the 3 domains.
  댓글 수: 1
Sanjib Banerjee
Sanjib Banerjee 2018년 4월 10일
Thank you....much appreciated Razvan, I shall try with my dataset. Cheers. Sanjib

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by