Add IndirectTransform for lazy coordinate resolution #31487
Closed
dikshajangra12918-oss wants to merge 8 commits intomatplotlib:mainfrom
Closed
Add IndirectTransform for lazy coordinate resolution #31487dikshajangra12918-oss wants to merge 8 commits intomatplotlib:mainfrom
dikshajangra12918-oss wants to merge 8 commits intomatplotlib:mainfrom
Conversation
Setting patchA on Annotation.arrow_patch has no visible effect because the arrow position is not recomputed. This change ensures that the annotation is marked as stale when patchA changes, triggering proper recomputation during rendering.
Add logic to prevent overriding user-set patchA in update_positions. Fixes issues matplotlib#28316.
Add test to verify that manually set patchA on annotation arrow is preserved after draw.
1. Add 2 blank lines before function definition 2. Split long comment line to stay within 80 chars
Only update patchA internally if user has not manually set it.
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
While exploring issue #22223, I noticed that the coordinate dispatch logic in '_get_xy_transform()' is tightly coupled inside '_AnnotationBase' class in the 'text.py'.
This PR adds 'IndirectTransforms' - a new class in 'transfroms.py' that wraps a callable and resolves it lazily at draw time.
How this fixes #22223
Currently, there is no clean way to position an artist relative to multiple other artists combined. The problem is that bounding boxes of artists are not known untill draw time.
'IndirectTransform' solves this by storing a callable (like a lambda) that gets callled at draw time - when bounding boxes are finally available. This means you can now do: