The MATLAB traditions list everything in the plot, including the recommendations that you pointed to the plot.
Fiction get around this to do
*Plot
*Add legend
*Add guidelines
However, MATLAB puts the very last lines in front, that is, the guidelines then sit on the displayed data; ugly and distracting.
Similar problems arise at any time when you create a complex plot, legenddistracting and capturing everything, and workarounds with building order can be ugly
Code example:
%**** Optional guidelines
figure(1)
plot([2 2],[0,1],'k--'); hold on
%**** DATA
N = 4;
y=rand(5,N);
x=1:1:5;
for plotLoop=1:N;
%* Plot
figure(1)
plot(x,y(plotLoop,:));
hold on
end
%*****LEGEND
hLegend = legend(LegTxt,...
'interpreter','latex',...
'location','eastoutside')
(reorder the code block order to reproduce the situations mentioned above)
How to reasonably fix this?
source
share