Skip to content

Commit c702a8f

Browse files
committed
Squash past 7 commits - test gid gets passed to the renderer
1 parent 0e9faba commit c702a8f

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

lib/matplotlib/tests/test_backend_svg.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from matplotlib.testing.decorators import check_figures_equal, image_comparison
1616
from matplotlib.testing._markers import needs_usetex
1717
from matplotlib import font_manager as fm
18+
from matplotlib.offsetbox import (OffsetImage, AnnotationBbox)
1819

1920

2021
def test_visibility():
@@ -588,3 +589,37 @@ def test_svg_font_string(font_str, include_generic):
588589

589590
assert font_info == f"{size}px {font_str}"
590591
assert text_count == len(ax.texts)
592+
593+
594+
def test_annotationbbox_gid():
595+
# Test that object gid appears in the AnnotationBbox
596+
# in output svg.
597+
fig = plt.figure()
598+
ax = fig.add_subplot()
599+
arr_img = np.ones((32, 32))
600+
xy = (0.3, 0.55)
601+
602+
imagebox = OffsetImage(arr_img, zoom=0.1)
603+
imagebox.image.axes = ax
604+
605+
ab = AnnotationBbox(imagebox, xy,
606+
xybox=(120., -80.),
607+
xycoords='data',
608+
boxcoords="offset points",
609+
pad=0.5,
610+
arrowprops=dict(
611+
arrowstyle="->",
612+
connectionstyle="angle,angleA=0,angleB=90,rad=3")
613+
)
614+
ab.set_gid("a test for issue 20044")
615+
ax.add_artist(ab)
616+
fig.canvas.draw()
617+
618+
fd = BytesIO()
619+
fig.savefig(fd, format='svg')
620+
fd.seek(0)
621+
buf = fd.read().decode()
622+
fd.close()
623+
624+
expected = '<g id="a test for issue 20044">'
625+
assert expected in buf

0 commit comments

Comments
 (0)