Ordering datasets in a single plot
Afficher commentaires plus anciens
Hello,
Does anyone know how to change the order of datasets included in a single plot. I have plotted 4 variables and would like to rearrange their order. I can't find out how to do this. The default for plotting seems to be the order in which you updated the plot.
Thanks,
2 commentaires
Sean de Wolski
le 4 Avr 2011
Can you show us a small example please? (input/operation/output)
Dave C
le 4 Avr 2011
Réponses (3)
Sean de Wolski
le 4 Avr 2011
figure; hold on
H(1) = plot(data1(:,1),data1(:,2),'r-')
H(2) = plot(data2(:,1),data2(:,2),'g*')
H(3) = plot(data3(:,1),data3(:,2),'bp')
H(4) = plot(data4(:,1),data4(:,2),'k:')
legend(H([3 2 1 4]),'3','2','1','4')
Paulo Silva
le 4 Avr 2011
d1=plot(data1(:,1),data1(:,2))
d2=plot(data2(:,1),data2(:,2))
d3=plot(data3(:,1),data3(:,2))
d4=plot(data4(:,1),data4(:,2))
legend([d1 d2 d3 d4],'one','two','three','four')
You can change the order by rearranging the values [d1 d2 d3 d4], for example [d4 d3 d2 d1]
legend([d4 d3 d2 d1],'four','three','two','one')
d4,d3,d2,d1 are handles for the plot objects.
Dave C
le 4 Avr 2011
0 votes
Catégories
En savoir plus sur Annotations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!