MATLAB: Graph drawn over axis box- error in clipping or graphics object order

axisboxclippingplot

Hi,
I am adding some plots to a figure in a for loop. After the loop I add a box to the plot like this:
box on
set(gca,'FontSize',8,'FontWeight','bold','linewidth',1.3)
set(gca,'TickLength',[0.015, 0.01])
However, when exporting to pdf (I have also tried with tiff, svg, and emf, it's the same for all), at the points where the end of the plotted data meets the box of the figure, the plotted data lies on top as illustrated in this image:
My data extends outside of the plotted range, so Matlab is Clipping the data to fit it into the frame. However, when I want to have thick lines as shown in the image, the way this turns out doesn't look nice. I guess I either need to change the clipping, or to rearrange the order of the graphics objects, placing the box on top of the plot, but I haven't figured out how to do this. Anyone has an idea?
Thanks!

Best Answer

This worked for me - set the axes Layer to Top:
set(gca, 'Layer', 'Top')