Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 92543f9

Browse files
dikshajangra12918-ossapple
authored andcommitted
Preserve user-set patchA in Annotation.update_positions
Add logic to prevent overriding user-set patchA in update_positions. Fixes issues #28316.
1 parent a926a30 commit 92543f9

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

lib/matplotlib/text.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,14 +2199,18 @@ def update_positions(self, renderer):
21992199
xy=(bbox.x0 - pad / 2, bbox.y0 - pad / 2),
22002200
width=bbox.width + pad, height=bbox.height + pad,
22012201
transform=IdentityTransform(), clip_on=False)
2202-
old_patchA = self.arrow_patch.patchA
2203-
self.arrow_patch.set_patchA(patchA)
2204-
2205-
# Ensure arrow updates when patchA changes
2206-
if old_patchA is not patchA:
2207-
self.stale = True
2208-
2202+
# Check if user manually set patchA externally
2203+
current_patchA = self.arrow_patch.patchA
2204+
internal_patchA = getattr(self, '_internal_patchA', None)
22092205

2206+
if current_patchA is not internal_patchA:
2207+
# patchA was manually set by the user, do not override it
2208+
pass
2209+
else:
2210+
# patchA was set internally, update it.
2211+
self.arrow_patch.set_patchA(patchA)
2212+
self._internal_patchA = patchA
2213+
22102214
@artist.allow_rasterization
22112215
def draw(self, renderer):
22122216
# docstring inherited

0 commit comments

Comments
 (0)