{{ message }}
Fix PDF path collection culling for hexbin offsets#32000
Open
yuzie007 wants to merge 2 commits into
Open
Conversation
5 tasks
1cec52b to
3e5af6f
Compare
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
This PR fixes a PDF backend regression where visible
hexbincells can be incorrectly skipped in Matplotlib 3.11.0.Closes #31999.
PR #30746 added path collection culling to the PDF backend to avoid bloated PDFs when many colored
scattermarkers are fully outside the canvas. That optimization works forscatter, where transformed offsets correspond to marker centers in canvas coordinates. However,hexbinuses a repeated hexagon path with offsets transformed byAffineDeltaTransform(self.transData). Those transformed offsets are displacements, not absolute canvas-space markercenters.
The PDF backend was culling collections by checking the transformed offset plus an approximate marker extent. For
hexbin, this can classify visible cells as off-canvas, especially when offsets are negative, so the PDF output loses part of the plot while raster output renders correctly.This PR keeps the optimization from #30746, but changes the culling check to use the actual transformed reusable path bounds translated by each offset. This preserves PDF size improvements for truly off-canvas
scattermarkers while correctly renderinghexbinand other collections whose transformed offsets are not absolute marker centers. This fix make the example in #31999 work as expected.A PDF regression test for
hexbinwith negative offsets, compared against an equivalent shifted reference.AI Disclosure
Agentic AI was employed to identify the origin of the issue, make the original fix, add the original test, and write the original issue and the PR description. The AI suggestions were reviewed and polished by human.
PR checklist
Documentation complies with general and docstring guidelines