MATLAB: Drawing a line without creating a legend entry

legendlineplot

In the MWE below, the green line shows up as the second row of the legend box. I want to be able to draw lines and incrementally build the legend as illustrated, but without having the line enter into the legend as it does in this example. Obviously, if I do all the plots before drawing the lines, and then use AutoUpdate off, I can accomplish this, but sometimes I need to intersperse lines and plots as in the example.
Is there any way to do this?
close all ; hold on;plot(1:10);Legend = {'line 1'};h=line([1,10],[6,6],'Color','g');hold on;plot(10:-1:1);Legend=[Legend,'line 2'];legend(Legend)

Best Answer

You can set the IconDisplayStyle of the Annotation property in order to exclude a graphics object from automatic legend.