防止特定的图条目显示在MATLAB图图例上 [英] Prevent specific plot entry from being displayed on a MATLAB plot legend
本文介绍了防止特定的图条目显示在MATLAB图图例上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要防止在Matlab图例上显示特定的图条目.
I need to prevent a specific plot entry from being displayed on a Matlab plot legend.
示例:
% x and y are any plot data
for i=1:5
plot(x,y);
plot(x2,y2,'PleaseNoLegend!'); % I need to hide this from legend
end
legend('show');
plot命令中是否可以设置任何标志,以便该特定条目不会显示在图例中?
Is there any flag I can set inside the plot command so this specific entry doesn't show up in legend?
推荐答案
您可以通过将'HandleVisibility'
属性设置为'off'
来实现.请注意,这会将这些图的句柄隐藏到所有函数中,而不仅仅是 legend
.
You can achieve that by setting the 'HandleVisibility'
property to 'off'
. Note that this hides the handles of those plots to all functions, not just to legend
.
例如,
hold on
for k = 1:3
x = 1:10;
y = rand(1,10);
x2 = x;
y2 = y + 2;
plot(x,y);
plot(x2,y2,'--','HandleVisibility','off'); % Hide from legend
end
legend('show')
产生图形
这篇关于防止特定的图条目显示在MATLAB图图例上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文