I like to plot two groups of lines in the same plot. Each group has two lines with same color and I have to draw them in the order of one group after another group. I try to
Actually, there is a non-hack way to do this, using hggroups. The below plots several lines, but the legend treats them as just two:
t = 0:.1:2*pi;
for k=1:5
offset = k/7;
m(:,k) = t+offset';
end
hSLines = plot(t,sin(m),'Color','b');hold on
hCLines = plot(t,cos(m),'Color','g');
hSGroup = hggroup;
hCGroup = hggroup;
set(hSLines,'Parent',hSGroup)
set(hCLines,'Parent',hCGroup)
% Include these hggroups in the legend:
set(get(get(hSGroup,'Annotation'),'LegendInformation'),...
'IconDisplayStyle','on');
set(get(get(hCGroup,'Annotation'),'LegendInformation'),...
'IconDisplayStyle','on');
legend('Sine','Cosine')
(shamelessly copied from http://www.mathworks.se/help/matlab/creating_plots/controlling-legends.html)