在Matlab中更改图例图 [英] Change Legend diagram in matlab
本文介绍了在Matlab中更改图例图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些基本上可以做到这一点的代码:
I have some code that basically does this:
for i = 1:length(ReliabilityStruct)
if (FailureFlags(i) == 0)
plot(X(i), Y(i), '.b');
elseif (FailureFlags(i) == 1)
plot(X(i), Y(i), 'or');
elseif (FailureFlags(i) == 2)
plot(X(i), Y(i), 'og');
elseif (FailureFlags(i) == 3)
plot(X(i), Y(i), 'ok');
else
fprintf('\nUnknown Flag, check Data\n')
return
end
end
drawnow;
legend('Recovery', '1', '2', '3');
所以我的目标是制作一个对不同标志具有不同符号的图形.见下文:
So my aim is to make a graph that has different symbols for different flags. See below:
如您所见,图例并不完全适合数据.您如何更改每个图例条目来解决此问题?或者,有没有更好的方法来解决这个问题?
As you can see, the Legend doesn't exactly fit the data. How can you change each of the legend entries to fix this up? Alternatively, is there a better way to approach this?
推荐答案
我认为您可以使用类似的东西(额外的好处是可以避免循环!):
I think you can use something like this (added bonus is that you avoid loops!):
ind = FailureFlags==0;
plot(X(ind), Y(ind), '.b');
ind = FailureFlags==1;
plot(X(ind), Y(ind), 'or');
ind = FailureFlags==2;
plot(X(ind), Y(ind), 'og');
ind = FailureFlags==3;
plot(X(ind), Y(ind), 'ok');
legend('Recovery', '1', '2', '3');
这篇关于在Matlab中更改图例图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文