How to set marker groups in one plot?

조회 수: 4 (최근 30일)
Leon 2020년 2월 17일
댓글: Leon 2020년 2월 18일
I have matrix A like the below. The first column is the group number.
% GroupNo, X, Y
1, x1, y1
1, x2, y2
1, x3, y3
2, x4, y4
2, x5, y5
It's very important I plot these data together based on the below commands, so that they can all share one ButtonDownFcn.
h1 = plot(app.Plot1, A(:,1), A(:,2), '^', 'markersize',10);
h1.ButtonDownFcn = {@FunctionSalOxy1, app, A(:,1), A(:,2)};
My question is how do I set the markers of different groups differently. For example, the index of Group 1 should be: Ind1 = A(:,1)==1;
Many thanks!
  댓글 수: 1
Leon 2020년 2월 18일
Many thanks for your help!

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

채택된 답변

Joseph Cheng
Joseph Cheng 2020년 2월 18일
편집: Joseph Cheng 2020년 2월 18일
Here is a snippet of code that should help you out.
%Dummy data
GroupNo =[1 1 1 2 2 2 3 3 4]
A = randi(100,numel(GroupNo),2);
%list of all makers. if number of groups is greater than this you can use mod()
%to force a repeat back through list of markers.
%additionally you can make a list of colors too so you can have combinations of colors
%and markers to designate (though if you get that far plots are usually a mess at that point)
marker ='.ox+*sdv^<>ph';
hax =axes(hfig);
%loop through each unique group number and only plot those rows
for ind = 1:numel(unique(GroupNo))
%better way than h1,h2.... hN.
hplot(ind) = plot(hax,A(GroupNo==ind,1), A(GroupNo==ind,2),[marker(ind) '-'], 'markersize',10);

추가 답변 (0개)


Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기




Community Treasure Hunt

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

Start Hunting!

Translated by