Multiple legends are drawn separately in matlab drawing

In matlab drawing, when there are many lines, the legend becomes longer and blocks the original image/classify the legend. The solution is to divide the legend into multiple.

1. Display multiple legends together

r = 10;
a = 0;
b = 0;
t=0:0.1:2.1*pi;
x=a+r*cos(t);
y=b+r*sin(t);
plot(x,y,'r','linewidth',4);hold on
axis equal
plot([0 0],[1 10],'b','linewidth',4);
legend('圆形','line')

Insert image description here

2. Display multiple legends separately

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 on
axis equal
A2=plot([0 0],[1 10],'b','linewidth',4);%直线
legend([A1],'圆形')
ah=axes('position',get(gca,'position'),...
             'visible','off');
legend(ah,[A2],'line')

Insert image description here

Guess you like

Origin blog.csdn.net/iii66yy/article/details/132307227