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

Skip to content

Commit 2f804e7

Browse files
Preserve user-set patchA in Annotation.update_positions
Add logic to prevent overriding user-set patchA in update_positions. Fixes issues #28316.
1 parent 5cecde1 commit 2f804e7

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
@@ -2101,14 +2101,18 @@ def update_positions(self, renderer):
21012101
xy=(bbox.x0 - pad / 2, bbox.y0 - pad / 2),
21022102
width=bbox.width + pad, height=bbox.height + pad,
21032103
transform=IdentityTransform(), clip_on=False)
2104-
old_patchA = self.arrow_patch.patchA
2105-
self.arrow_patch.set_patchA(patchA)
2106-
2107-
# Ensure arrow updates when patchA changes
2108-
if old_patchA is not patchA:
2109-
self.stale = True
2110-
2104+
# Check if user manually set patchA externally
2105+
current_patchA = self.arrow_patch.patchA
2106+
internal_patchA = getattr(self, '_internal_patchA', None)
21112107

2108+
if current_patchA is not internal_patchA:
2109+
# patchA was manually set by the user, do not override it
2110+
pass
2111+
else:
2112+
# patchA was set internally, update it.
2113+
self.arrow_patch.set_patchA(patchA)
2114+
self._internal_patchA = patchA
2115+
21122116
@artist.allow_rasterization
21132117
def draw(self, renderer):
21142118
# docstring inherited

0 commit comments

Comments
 (0)