File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 15
15
from matplotlib .testing .decorators import check_figures_equal , image_comparison
16
16
from matplotlib .testing ._markers import needs_usetex
17
17
from matplotlib import font_manager as fm
18
+ from matplotlib .offsetbox import (OffsetImage , AnnotationBbox )
18
19
19
20
20
21
def test_visibility ():
@@ -588,3 +589,37 @@ def test_svg_font_string(font_str, include_generic):
588
589
589
590
assert font_info == f"{ size } px { font_str } "
590
591
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
You can’t perform that action at this time.
0 commit comments