ENH: Add pre_draw_event callback#31887
Open
Vikash-Kumar-23 wants to merge 2 commits into
Open
Conversation
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.
Closes #17168.
This PR adds a new pre_draw_event callback that is emitted during Figure.draw() after layout and geometry have been finalized but before any rendering occurs.
Currently, draw_event is emitted only after rendering has completed, which makes it difficult for callbacks to inspect or modify artists based on their final geometry before pixels are written to the renderer.
The new event is emitted after _get_draw_artists(renderer) so that:
while still allowing callbacks to run before rendering begins.
One motivating use case is overlay systems that need access to final axes geometry before rendering occurs without requiring an additional draw pass.
Minimum self-contained example
Output:
pre_draw_eventis emitted before rendering begins, whiledraw_eventis emitted after rendering completes.AI Disclosure
AI tools were used to assist in drafting text and suggesting validation scenarios.
All code changes, final implementation decisions, and verification were done manually.
PR checklist