Adding legend for iteration and if condition graph
4 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
jonas
2018-5-26
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')
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!