MATLAB: Line marker specifiers duplicated – subplot legend

legendsubplot

I am using subplots (3X4) in a figure. I have 9 plots which means in the third row, plots 10, 11, and 12 are free. I am trying to put my legend in the space of plot 10. Could anyone explain why there are some extra symbols creeping in between (shown inside the red circle in picture)? The relevant part of my code is as follows:
subplot(3,4,10)
axis off
plot(p1, 'ks', 'MarkerEdgeColor','k', 'MarkerFaceColor','w','MarkerSize',8);
axis off
plot(p2, 'ko', 'MarkerEdgeColor','k', 'MarkerFaceColor','k','MarkerSize',5);
hold on;
axis off
plot(p3, 'k^', 'MarkerEdgeColor','k', 'MarkerFaceColor','w','MarkerSize',7);
hold on;
axis off
plot(p4, 'k^', 'MarkerEdgeColor','k', 'MarkerFaceColor','k','MarkerSize',7);
hold on;
axis off
plot(p5, '-k', 'MarkerEdgeColor','k', 'MarkerFaceColor','k','MarkerSize',2);
hold on;
axis off
plot(p6, '--k', 'MarkerEdgeColor','k', 'MarkerFaceColor','k','MarkerSize',2);
hold on;
legend(...
'abc',...
'abc',...
'abc',...
'abc',...
'abc',...
'abc',...
'Location', 'North');
legend('boxoff')
title('Legend')

Best Answer

Are you sure you're not just seeing your plots behind the legend? Things are pretty crowded in that tiny axes. What happens if you add this:
set(get(gca,'Children'),'Visible','off')
to hide the plots in that axes.
BTW, I don't think your code actually matches the picture. Your code doesn't do "hold on" until after you plot p2. That means that plotting p2 would have overwritten p1. And yet we can see some square markers.