@@ -76,10 +76,10 @@ def assert_update(
76
76
def test_add_annotation_no_grid (self ):
77
77
# Paper annotation
78
78
fig = go .Figure ()
79
- fig .add_annotation (text = "A" )
79
+ fig .add_annotation (text = "A" , yref = "paper" )
80
80
annot = fig .layout .annotations [- 1 ]
81
81
self .assertEqual (annot .text , "A" )
82
- self .assertEqual (annot .xref , "paper" )
82
+ self .assertEqual (annot .xref , None )
83
83
self .assertEqual (annot .yref , "paper" )
84
84
85
85
# Not valid to add annotation by row/col
@@ -88,10 +88,10 @@ def test_add_annotation_no_grid(self):
88
88
89
89
def test_add_annotations (self ):
90
90
# Paper annotation
91
- self .fig .add_annotation (text = "A" )
91
+ self .fig .add_annotation (text = "A" , yref = "paper" )
92
92
annot = self .fig .layout .annotations [- 1 ]
93
93
self .assertEqual (annot .text , "A" )
94
- self .assertEqual (annot .xref , "paper" )
94
+ self .assertEqual (annot .xref , None )
95
95
self .assertEqual (annot .yref , "paper" )
96
96
97
97
# (1, 1) annotation
@@ -138,8 +138,10 @@ def test_select_annotations_no_grid(self):
138
138
139
139
def test_select_annotations (self ):
140
140
(
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" )
143
145
.add_annotation (text = "B" , arrowcolor = "red" , row = 1 , col = 1 )
144
146
.add_annotation (text = "C1" , row = 1 , col = 2 )
145
147
.add_annotation (text = "C2" , row = 1 , col = 2 , secondary_y = True )
@@ -151,13 +153,13 @@ def test_select_annotations(self):
151
153
self .assert_selected ("annotations" , [0 , 2 ], selector = dict (arrowcolor = "red" ))
152
154
self .assert_selected ("annotations" , [2 , 3 , 4 ], row = 1 )
153
155
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" ) )
155
157
self .assert_selected ("annotations" , [4 ], secondary_y = True )
156
158
157
159
def test_select_shapes (self ):
158
160
(
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" )
161
163
.add_shape (opacity = 0.3 , fillcolor = "red" , row = 1 , col = 1 )
162
164
.add_shape (opacity = 0.4 , row = 1 , col = 2 )
163
165
.add_shape (opacity = 0.5 , row = 1 , col = 2 , secondary_y = True )
@@ -169,13 +171,15 @@ def test_select_shapes(self):
169
171
self .assert_selected ("shapes" , [0 , 2 ], selector = dict (fillcolor = "red" ))
170
172
self .assert_selected ("shapes" , [2 , 3 , 4 ], row = 1 )
171
173
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" ) )
173
175
self .assert_selected ("shapes" , [4 ], secondary_y = True )
174
176
175
177
def test_select_images (self ):
176
178
(
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" )
179
183
.add_layout_image (opacity = 0.3 , source = "red" , row = 1 , col = 1 )
180
184
.add_layout_image (opacity = 0.4 , row = 1 , col = 2 )
181
185
.add_layout_image (opacity = 0.5 , row = 1 , col = 2 , secondary_y = True )
@@ -187,7 +191,7 @@ def test_select_images(self):
187
191
self .assert_selected ("images" , [0 , 2 ], selector = dict (source = "red" ))
188
192
self .assert_selected ("images" , [2 , 3 , 4 ], row = 1 )
189
193
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" ) )
191
195
self .assert_selected ("images" , [4 ], secondary_y = True )
192
196
193
197
def test_update_annotations (self ):
0 commit comments