Multiple legend location in figure

1 次查看(过去 30 天)
Hi, I have a code similar to below where I want to put the legends at different location. This code is running well in 2014b but not in 2017a. Please help me out. Also tried with 'yyaxis' command but no luck.
a=[-360:1:360];
x=(2*pi/180).*a;
y1=sin(x);
y2=cos(x);
y3=sin(x).*cos(x);
figure
[ax,h1,h2]=plotyy(a,y1,a,y3);
h3=line(a,y2,'Color','r','LineWidth',1.5,'Parent',ax(1));
h4=line(a,zeros(1,721),'Color','k');
set(ax,'XLim',[-360 360]);
set(ax(1),'ylim',[-1.5 1.5])
set(ax(2),'ylim',[-1 1])
legend(ax(1),'sin','cos','Location','NorthEast')
legend(ax(2),'sin * cos','Location','NorthWest')
The above is my code.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

产品


版本

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by