Add IndirectTransform for lazy coordinate resolution#31488
Add IndirectTransform for lazy coordinate resolution#31488dikshajangra12918-oss wants to merge 14 commits intomatplotlib:mainfrom
Conversation
b79b409 to
840e1fd
Compare
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.
Only update patchA internally if user has not manually set it.
840e1fd to
0adf520
Compare
|
I suggest this is put on hold until @dikshajangra12918-oss's other PR #31547 is resolved. There is clearly some confusion there and I do not think it will be helped by trying to work on two PRs at once. |
Okay sir. |
#31547 is conceptually much much simpler, so one of the things we're trying to gauge is how well you understand what you're doing and how responsive you are to feedback before we invest time on this PR, which is much more work to review. Also I'm putting this PR into draft b/c it's missing tests and therefore very much not ready for review. (And the unrelated patch stuff should not be here either). |
Thankyou for the feedback! I understand - I will focus on resolving #31547 first. For this PR, I will add the missing tests and remove the unrelated patch changes before marking it ready for review. |
PR Summary
While exploring issue #22223, I noticed that the coordinate dispatch logic in '_get_xy_transform()' is tightly coupled inside '_AnnotationBase' class in 'text.py'.
This PR adds 'IndirectTransform' - a new class in 'transforms.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 called at draw time - when bounding boxes are finally available. This means you can now do: