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

Skip to content

Commit 5cecde1

Browse files
Fix Annotation arrow not updating after setting patchA
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.
1 parent 0adda9f commit 5cecde1

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

lib/matplotlib/text.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,8 +2101,14 @@ 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
21042105
self.arrow_patch.set_patchA(patchA)
21052106

2107+
# Ensure arrow updates when patchA changes
2108+
if old_patchA is not patchA:
2109+
self.stale = True
2110+
2111+
21062112
@artist.allow_rasterization
21072113
def draw(self, renderer):
21082114
# docstring inherited

0 commit comments

Comments
 (0)