How to set marker groups in one plot?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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!
Réponse acceptée
Joseph Cheng
le 18 Fév 2020
Modifié(e) : Joseph Cheng
le 18 Fév 2020
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';
hfig=figure(1);
hax =axes(hfig);
hold(hax,'on')
%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);
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Annotations 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!