I have a figure created with plotyy. I want to place legends near to their respective axes , i.e., at northeast for left y-axis and at northwest for right y-axis. The following set of commands just places the last legend command. Please, help.
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','NorthWest')legend(ax(2),{'h2'},'Location','NorthEast');
Best Answer