Snap markers to subpixels instead of whole ones#32108
Draft
QuLogic wants to merge 2 commits into
Draft
Conversation
We cache the marker for performance, but this causes it to look very pixel-grid aligned, especially if there are multiple in a regular pattern, or they are animated. Apply the same algorithm as mplcairo noted by @anntzer in matplotlib#7233, specifically, render and cache the marker in *n_subdiv* levels in each direction, and pick the closest one for each marker. Fixes matplotlib#7233
QuLogic
commented
Jul 23, 2026
Comment on lines
+501
to
+504
| // TODO: Pixel markers *must* be drawn snapped. | ||
| auto const& is_pixel_marker = false; | ||
| // py_eq(marker_path, PIXEL_MARKER.attr("get_path")()) | ||
| // && marker_trans == PIXEL_MARKER.attr("get_transform")().cast<agg::trans_affine>(); |
Member
Author
There was a problem hiding this comment.
mplcairo special-cases the pixel marker; I have not checked how that turns out or whether that is necessary.
Comment on lines
+532
to
+535
| auto marker_path_snapped = PathSnapper{ | ||
| marker_path_nan_removed, | ||
| gc.snap_mode, marker_path.total_vertices(), | ||
| points_to_pixels(gc.linewidth)}; |
Member
Author
There was a problem hiding this comment.
I'm not 100% certain we should be snapping here for each of the cached subpixel markers. It affects a lot more test images if we drop this though.
Member
Author
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
We cache the marker for performance, but this causes it to look very pixel-grid aligned, especially if there are multiple in a regular pattern, or they are animated.
Apply the same algorithm as mplcairo noted by @anntzer in #7233, specifically, render and cache the marker in n_subdiv levels in each direction, and pick the closest one for each marker.
Fixes #7233
AI Disclosure
None
PR checklist