This enhancement has been incorporated in Release 2008a (R2008a). For previous product releases, read below for possible workarounds:
The PLOTYY command creates two axes. In the first axes it plots the first (x1,y1) data set and in the second axes it plots the second (x2,y2) data set.
With the code above, two axes are created and two lines are plotted. The first axes has a white color and the second axes has a color of 'none'. This allows you to see the line drawn in the first axes. When the LEGEND command is executed it obtains the line information from the current axes which contains only one line. Therefore, the resulting legend only shows one line.
To create a plotyy figure with a legend, try the following:
x = 1:10;
y = 10:-1:1;
[ax,h1,h2] = plotyy(x,x,x,y);
axes(ax(2))
[legh, objh] = legend([h1 h2],'str1', 'str2');
Best Answer