基本用法:
legend({'str1','str2','strn'});
高级用法1:指定legend显示的位置:
legend({'str1','str2','strn'},1);
legend({'str1','str2','strn'},2);
legend({'str1','str2','strn'},'Location','SouthEast');
可选的位置很多:
North:Inside plot box near top
South:Inside bottom
EastI:nside right
West:Inside left* U$ D" a* Q/ Y: }- I: v: [
NorthEast:Inside top right (default)2 i/ U; O: d* S. v3 G) K" S
NorthWest:Inside top left( X! A1 U' W: V7 U8 {: s& |
SouthEast:Inside bottom right0 U" X. X. i; V; Q. G0 s
SouthWest:Inside bottom left' ^! L3 J5 V) e7 z4 v
NorthOutside:Outside plot box near top2 [9 c3 P( y, `) j: N* J. r
SouthOutside:Outside bottom
EastOutside:Outsideright
WestOutside:Outside left: C% S" n! b" F7 c- A2 ~5 K( |7 f
NorthEastOutside:Outside top right
NorthWestOutside:Outside top left
SouthEastOutside:Outside bottom right6 G {9 P6 P2 I; L. ?
SouthWestOutside:Outside bottom left
Best:Least conflict with data in plot
BestOutside:Least unused space outside plot
通常,用'Best‘比较不错
高级用法2:指定显示某几条曲线的legend:
方法1:复杂到吐血
例如你有25条曲线,想显示其中1,6,11,16,21的legend,则
for i = [2:5 7:10 12:15 17:20 22:25]
set(get(get(H(i),'Annotation'),'LegendInformation'),'IconDisplayStyle','off');6 }8 [& f3 a1 e3 W+ d0 D
end
legend('1','6','11','16','21');
方法2:简单到郁闷
H = plot(data);
legend(H([1 6 11 16 21],'1,'6','11’,'16','21');
高级用法3:legend横排
hl = legend(H([1 6 11 16 21],'1,'6','11’,'16','21');
set(hl,'Orientation','horizon')
高级用法4:不显示方框:
hl = legend(H([1 6 11 16 21],'1,'6','11’,'16','21');* A" q* {; d+ V" N0 Z
set(hl,'Box','off');
| 欢迎光临 EDA365电子论坛网 (https://bbs.eda365.com/) | Powered by Discuz! X3.2 |