小工具知识网

当前位置: 首页 > 行业知识 > Matlab中图例的位置(图例放在图的上方、下方、左方、右方、图外面)等

行业知识

Matlab中图例的位置(图例放在图的上方、下方、左方、右方、图外面)等

2026-10-24 11:21:09 来源:互联网转载

一、图例默认位置

默认���位置在NorthEast

r = 10;a = 0;b = 0;t=0:0.1:2.1*pi;x=a+r*cos(t);y=b+r*sin(t);A1=plot(x,y,'r','linewidth',4);%圆hold onaxis equalA2=plot([0 0],[1 10],'b','linewidth',4);%直线legend([A1,A2],'圆形','line')

二、通过Location对legend的位置进行改变

变为North

r = 10;a = 0;b = 0;t=0:0.1:2.1*pi;x=a+r*cos(t);y=b+r*sin(t);A1=plot(x,y,'r','linewidth',4);%圆hold onaxis equalA2=plot([0 0],[1 10],'b','linewidth',4);%直线legend([A1,A2],'圆形','line','Location','North')

三、图例放在图的其他位置

设置位置
Northinside plot box near top
Southinside bottom
East inside right
Westinside left
NorthEastinside top right (default for 2-D plots)
NorthWestinside top left
SouthEastinside bottom right
SouthWest’inside bottom left
NorthOutsideoutside plot box near top
SouthOutsideoutside bottom
EastOutsideoutside right
WestOutsideoutside left
NorthEastOutsideoutside top right (default for 3-D plots)
NorthWestOutsideoutside top left
SouthEastOutsideoutside bottom right
SouthWestOutsideoutside bottom left
Bestleast conflict with data in plot
BestOutsideleast unused space outside plot

直接替换即可

四、图例放在图的外面

r = 10;a = 0;b = 0;t=0:0.1:2.1*pi;x=a+r*cos(t);y=b+r*sin(t);A1=plot(x,y,'r','linewidth',4);%圆hold onaxis equalA2=plot([0 0],[1 10],'b','linewidth',4);%直线legend([A1,A2],'圆形','line','Location',' WestOutside')

五、只显示一个曲线

r = 10;a = 0;b = 0;t=0:0.1:2.1*pi;x=a+r*cos(t);y=b+r*sin(t);A1=plot(x,y,'r','linewidth',4);%圆hold onaxis equalA2=plot([0 0],[1 10],'b','linewidth',4);%直线legend([A1],'圆形','Location',' WestOutside')

上一篇:小程序分享秘籍,轻松掌握分享给好友的正确姿势!

下一篇:Flash下载秘籍,轻松掌握高效下载技巧