Fix a bug of ignoring the closing path segment when automatically determining whether to snap#32018
Open
ayshih wants to merge 2 commits into
Open
Fix a bug of ignoring the closing path segment when automatically determining whether to snap#32018ayshih wants to merge 2 commits into
ayshih wants to merge 2 commits into
Conversation
8e7924c to
5a00b40
Compare
4848ceb to
e5d637f
Compare
QuLogic
reviewed
Jul 8, 2026
QuLogic
left a comment
Member
There was a problem hiding this comment.
Can you run oxipng on the new images? If I've read GitHub's annotations correctly, some of them have grown quite a bit.
Contributor
Author
Ah, good catch! Differences are now much more reasonable after using oxipng. |
QuLogic
approved these changes
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR summary
The current code for automatic determination of whether a path should be snapped – by checking whether all line segments are either horizontal or vertical – neglects to check the closing line segment for a closed path. That is, a closed path will be automatically determined to be snappable even when the closing line segment is not horizontal or vertical as long as all other line segments are either horizontal or vertical. This PR fixes that oversight.
A not-uncommon place for this bug to have an effect in the wild is when plotting contours, and one contour region is just a triangular section at the corner of the plot. If the diagonal of that triangle happens to be the closing line segment, then that contour region will snap, while its adjacent contour region will typically not snap. A handful of figure tests show this effect.
Here is a minimal example illustrating the bug:
Before this PR
The gap between the two triangles is not a consistent width, showing that the two triangles are not snapping the same. The gap will change/flicker if the plot window is resized due to this difference in snapping.

After this PR
The gap between the two triangles is a consistent width, showing that both triangles are snapping the same.

AI Disclosure
No AI was used
PR checklist