Filter löschen
Filter löschen

Adding legend for iteration and if condition graph

10 Ansichten (letzte 30 Tage)
Kwan Chak Yin
Kwan Chak Yin am 26 Mai 2018
Beantwortet: jonas am 26 Mai 2018
Good day, I currently having problem in insert the legend to a graph. Basically this is my coding in plotting the graph. I am using the DisplayName but the legend is missing also. Is it any other ways to put the legend into my plot?
title('Graph of behaviour against iteration');
xlabel('iteration t');
ylabel('behaviour value');
if max_euc_dist<0.056
plot(i,dataCopyS5(i,:),'g.','MarkerSize',4,'DisplayName','Normal');hold on
else
plot(i,dataCopyS5(i,:),'m+','MarkerSize',4,'DisplayName','Anomaly');hold on
end
The graph cannot change to scatter plot as the size of dataCopyS5 is 1000x8. Hope that my problem faced can be solved. Thank you.

Antworten (1)

jonas
jonas am 26 Mai 2018
Try this,
title('Graph of behaviour against iteration');
xlabel('iteration t');
ylabel('behaviour value');
if max_euc_dist<0.056
h1=plot(i,dataCopyS5(i,:),'g.','MarkerSize',4);hold on
else
h2=plot(i,dataCopyS5(i,:),'m+','MarkerSize',4);hold on
end
legend([h1 h2],'Normal','Anomaly')

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by