Sometimes you need to exclude certain items from the legend in MATLAB figures, while keeping the data on the plot. Here is how you can do this:
h1=plot(x,1y1,x2,y2,x3,y3); %Now we can choose which DisplayNames we would like to include in the legend. %Notice that the order is reversed. legend([ax.Children(3),ax.Children(1)],[{'y1 display name'},{'y3 display name'}])