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

Skip to content

Commit aa4f232

Browse files
Add test_annotation_patchA_not_overridden function
Add test to verify that manually set patchA on annotation arrow is preserved after draw.
1 parent 2f804e7 commit aa4f232

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

lib/matplotlib/tests/test_text.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,3 +1236,16 @@ def test_text_tightbbox_outside_scale_domain():
12361236
invalid_text = ax.text(0, -5, 'invalid')
12371237
invalid_bbox = invalid_text.get_tightbbox(fig.canvas.get_renderer())
12381238
assert not np.isfinite(invalid_bbox.width)
1239+
def test_annotation_patchA_not_overridden():
1240+
# Test that manually setting patchA on annotation arrow is not overridden by update_positions. See GitHub issue #28316.
1241+
fig, ax = plt.subplots()
1242+
ann = ax.annotate(
1243+
'',
1244+
xy=(0.5, 0.6),
1245+
xytext=(0.2, 0.5),
1246+
arrowprops=dict(arrowstyle="->")
1247+
)
1248+
text = ax.text(0.2, 0.5, 'Text', ha='center', va='center')
1249+
ann.arrow_patch.set_patchA(text)
1250+
fig.draw_without_rendering()
1251+
assert ann.arrow_patch.patchA is text

0 commit comments

Comments
 (0)