Graph drawn over axis box- error in clipping or graphics object order
Afficher commentaires plus anciens
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!
Réponse acceptée
Plus de réponses (1)
Daniel Fleischer
le 8 Mar 2020
0 votes
I am able to move the axes on top of my lines with set(gca, 'Layer', 'top'), but the line still shows past when it runs on the edge of the axis. Is there any way to prevent this besides making the axis thicker to cover it, or using thinner lines?
1 commentaire
Adam Danz
le 18 Fév 2021
You have to set the ClippingStyle to rectangle for 2D plots
ax.ClippingStyle = 'rectangle';
Catégories
En savoir plus sur Annotations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!