My code looks like this:
n=-180:180;x=(pi/180).*n;y=sin(x);y2=sin(x).*cos(x);y3=cos(x);[ax h1 h2]=plotyy(n,y,n,y2)h3=line(n,y3,'Color','r','LineWidth',2,'Parent',ax(1))set(h1,'Color','k','LineStyle','-','LineWidth',1.0);set(h2,'Color','b','LineStyle','-','LineWidth',1.5);legend(ax(1),'h1','h3','Location','NorthEast')legend(ax(2),{'h2'},'Location','NorthWest');
the last legend command is working
n=-180:180;x=(pi/180).*n;y=sin(x);y2=sin(x).*cos(x);y3=cos(x);[ax h1 h2]=plotyy(n,y,n,y2)h3=line(n,y3,'Color','r','LineWidth',2,'Parent',ax(1))set(h1,'Color','k','LineStyle','-','LineWidth',1.0);set(h2,'Color','b','LineStyle','-','LineWidth',1.5);legend(ax(1),'h1','h3','Location','NorthEast')% legend(ax(2),{'h2'},'Location','NorthWest');
but after disabling the last legend command
Please help how to keep both the legend boxes.
Best Answer