@@ -76,10 +76,10 @@ def assert_update(
7676 def test_add_annotation_no_grid (self ):
7777 # Paper annotation
7878 fig = go .Figure ()
79- fig .add_annotation (text = "A" )
79+ fig .add_annotation (text = "A" , yref = "paper" )
8080 annot = fig .layout .annotations [- 1 ]
8181 self .assertEqual (annot .text , "A" )
82- self .assertEqual (annot .xref , "paper" )
82+ self .assertEqual (annot .xref , None )
8383 self .assertEqual (annot .yref , "paper" )
8484
8585 # Not valid to add annotation by row/col
@@ -88,10 +88,10 @@ def test_add_annotation_no_grid(self):
8888
8989 def test_add_annotations (self ):
9090 # Paper annotation
91- self .fig .add_annotation (text = "A" )
91+ self .fig .add_annotation (text = "A" , yref = "paper" )
9292 annot = self .fig .layout .annotations [- 1 ]
9393 self .assertEqual (annot .text , "A" )
94- self .assertEqual (annot .xref , "paper" )
94+ self .assertEqual (annot .xref , None )
9595 self .assertEqual (annot .yref , "paper" )
9696
9797 # (1, 1) annotation
@@ -138,8 +138,10 @@ def test_select_annotations_no_grid(self):
138138
139139 def test_select_annotations (self ):
140140 (
141- self .fig .add_annotation (text = "A1" , arrowcolor = "red" )
142- .add_annotation (text = "A2" , arrowcolor = "blue" )
141+ self .fig .add_annotation (
142+ text = "A1" , arrowcolor = "red" , xref = "paper" , yref = "paper"
143+ )
144+ .add_annotation (text = "A2" , arrowcolor = "blue" , xref = "paper" , yref = "paper" )
143145 .add_annotation (text = "B" , arrowcolor = "red" , row = 1 , col = 1 )
144146 .add_annotation (text = "C1" , row = 1 , col = 2 )
145147 .add_annotation (text = "C2" , row = 1 , col = 2 , secondary_y = True )
@@ -151,13 +153,13 @@ def test_select_annotations(self):
151153 self .assert_selected ("annotations" , [0 , 2 ], selector = dict (arrowcolor = "red" ))
152154 self .assert_selected ("annotations" , [2 , 3 , 4 ], row = 1 )
153155 self .assert_selected ("annotations" , [2 ], selector = dict (arrowcolor = "red" ), row = 1 )
154- self .assert_selected ("annotations" , [0 , 1 ], row = "paper" , col = "paper" )
156+ self .assert_selected ("annotations" , [0 , 1 ], dict ( yref = "paper" , xref = "paper" ) )
155157 self .assert_selected ("annotations" , [4 ], secondary_y = True )
156158
157159 def test_select_shapes (self ):
158160 (
159- self .fig .add_shape (opacity = 0.1 , fillcolor = "red" )
160- .add_shape (opacity = 0.2 , fillcolor = "blue" )
161+ self .fig .add_shape (opacity = 0.1 , fillcolor = "red" , xref = "paper" , yref = "paper" )
162+ .add_shape (opacity = 0.2 , fillcolor = "blue" , xref = "paper" , yref = "paper" )
161163 .add_shape (opacity = 0.3 , fillcolor = "red" , row = 1 , col = 1 )
162164 .add_shape (opacity = 0.4 , row = 1 , col = 2 )
163165 .add_shape (opacity = 0.5 , row = 1 , col = 2 , secondary_y = True )
@@ -169,13 +171,15 @@ def test_select_shapes(self):
169171 self .assert_selected ("shapes" , [0 , 2 ], selector = dict (fillcolor = "red" ))
170172 self .assert_selected ("shapes" , [2 , 3 , 4 ], row = 1 )
171173 self .assert_selected ("shapes" , [2 ], selector = dict (fillcolor = "red" ), row = 1 )
172- self .assert_selected ("shapes" , [0 , 1 ], row = "paper" , col = "paper" )
174+ self .assert_selected ("shapes" , [0 , 1 ], dict ( yref = "paper" , xref = "paper" ) )
173175 self .assert_selected ("shapes" , [4 ], secondary_y = True )
174176
175177 def test_select_images (self ):
176178 (
177- self .fig .add_layout_image (opacity = 0.1 , source = "red" )
178- .add_layout_image (opacity = 0.2 , source = "blue" )
179+ self .fig .add_layout_image (
180+ opacity = 0.1 , source = "red" , xref = "paper" , yref = "paper"
181+ )
182+ .add_layout_image (opacity = 0.2 , source = "blue" , xref = "paper" , yref = "paper" )
179183 .add_layout_image (opacity = 0.3 , source = "red" , row = 1 , col = 1 )
180184 .add_layout_image (opacity = 0.4 , row = 1 , col = 2 )
181185 .add_layout_image (opacity = 0.5 , row = 1 , col = 2 , secondary_y = True )
@@ -187,7 +191,7 @@ def test_select_images(self):
187191 self .assert_selected ("images" , [0 , 2 ], selector = dict (source = "red" ))
188192 self .assert_selected ("images" , [2 , 3 , 4 ], row = 1 )
189193 self .assert_selected ("images" , [2 ], selector = dict (source = "red" ), row = 1 )
190- self .assert_selected ("images" , [0 , 1 ], row = "paper" , col = "paper" )
194+ self .assert_selected ("images" , [0 , 1 ], dict ( yref = "paper" , xref = "paper" ) )
191195 self .assert_selected ("images" , [4 ], secondary_y = True )
192196
193197 def test_update_annotations (self ):
0 commit comments