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

Skip to content

Commit 5f966f5

Browse files
authored
Merge pull request #22457 from anntzer/abbc
Copy arrowprops argument to FancyAnnotationBbox.
2 parents f3a2d41 + 6345ef6 commit 5f966f5

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/matplotlib/offsetbox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ def __init__(self, offsetbox, xy,
13341334
xycoords=xycoords,
13351335
annotation_clip=annotation_clip)
13361336
self.offsetbox = offsetbox
1337-
self.arrowprops = arrowprops
1337+
self.arrowprops = arrowprops.copy() if arrowprops is not None else None
13381338
self.set_fontsize(fontsize)
13391339
self.xybox = xybox if xybox is not None else xy
13401340
self.boxcoords = boxcoords if boxcoords is not None else xycoords

lib/matplotlib/tests/test_offsetbox.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,13 @@ def test_annotationbbox_extents():
325325

326326
def test_zorder():
327327
assert OffsetBox(zorder=42).zorder == 42
328+
329+
330+
def test_arrowprops_copied():
331+
da = DrawingArea(20, 20, 0, 0, clip=True)
332+
arrowprops = {"arrowstyle": "->", "relpos": (.3, .7)}
333+
ab = AnnotationBbox(da, [.5, .5], xybox=(-0.2, 0.5), xycoords='data',
334+
boxcoords="axes fraction", box_alignment=(0., .5),
335+
arrowprops=arrowprops)
336+
assert ab.arrowprops is not ab
337+
assert arrowprops["relpos"] == (.3, .7)

0 commit comments

Comments
 (0)