本文为转载文章
版权声明:本文为CSDN博主「happyangry」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/happyangry/article/details/88290687
在MATLAB画图中,有时需要忽略某些legend,有几种方法可以实现:
1.在画不需要图例的线条时添加’HandleVisibility’,‘off’
x = linspace(0,pi);
y1 = cos (x);
plot(x,y1);
hold on
y2 = cos(2x);
plot(x,y2,‘HandleVisibility’,‘off’);
y3 = cos(3x);
plot(x,y3);
hold off
legend(‘First’,‘Third’)
2.在legend 函数 中添加subset,例如
x = linspace(0,pi);
y1 = cos(x);
p1 = plot(x,y1);
hold on
y2 = cos(2x);
p2 = plot(x,y2);
y3 = cos(3x);
p3 = plot(x,y3);
hold off
legend([p1 p3],{‘First’,‘Third’})
两者效果相同

免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删