MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_annotationbbox_gid

Function test_annotationbbox_gid

lib/matplotlib/tests/test_backend_svg.py:648–676  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

646
647
648def test_annotationbbox_gid():
649 # Test that object gid appears in the AnnotationBbox
650 # in output svg.
651 fig = plt.figure()
652 ax = fig.add_subplot()
653 arr_img = np.ones((32, 32))
654 xy = (0.3, 0.55)
655
656 imagebox = OffsetImage(arr_img, zoom=0.1)
657 imagebox.image.axes = ax
658
659 ab = AnnotationBbox(imagebox, xy,
660 xybox=(120., -80.),
661 xycoords='data',
662 boxcoords="offset points",
663 pad=0.5,
664 arrowprops=dict(
665 arrowstyle="->",
666 connectionstyle="angle,angleA=0,angleB=90,rad=3")
667 )
668 ab.set_gid("a test for issue 20044")
669 ax.add_artist(ab)
670
671 with BytesIO() as fd:
672 fig.savefig(fd, format='svg')
673 buf = fd.getvalue().decode('utf-8')
674
675 expected = '<g id="a test for issue 20044">'
676 assert expected in buf
677
678
679def test_svgid():

Callers

nothing calls this directly

Calls 7

OffsetImageClass · 0.90
AnnotationBboxClass · 0.90
figureMethod · 0.80
add_subplotMethod · 0.80
set_gidMethod · 0.45
add_artistMethod · 0.45
savefigMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…