@@ -71,6 +71,19 @@ def assert_update(
7171 # Check object unchanged
7272 self .assertEqual (obj , obj_orig )
7373
74+ def test_add_annotation_no_grid (self ):
75+ # Paper annotation
76+ fig = go .Figure ()
77+ fig .add_annotation (text = "A" )
78+ annot = fig .layout .annotations [- 1 ]
79+ self .assertEqual (annot .text , "A" )
80+ self .assertEqual (annot .xref , "paper" )
81+ self .assertEqual (annot .yref , "paper" )
82+
83+ # Not valid to add annotation by row/col
84+ with self .assertRaisesRegexp (Exception , "make_subplots" ):
85+ fig .add_annotation (text = "B" , row = 1 , col = 1 )
86+
7487 def test_add_annotations (self ):
7588 # Paper annotation
7689 self .fig .add_annotation (text = "A" )
@@ -111,6 +124,16 @@ def test_add_annotations(self):
111124 with self .assertRaisesRegexp (ValueError , "of type polar" ):
112125 self .fig .add_annotation (text = "D" , row = 2 , col = 2 )
113126
127+ def test_select_annotations_no_grid (self ):
128+ (
129+ self .fig .add_annotation (text = "A1" , arrowcolor = "red" )
130+ .add_annotation (text = "A2" , arrowcolor = "blue" )
131+ .add_annotation (text = "A3" , arrowcolor = "blue" )
132+ )
133+ self .assert_selected ("annotations" , [0 , 1 , 2 ])
134+ self .assert_selected ("annotations" , [0 ], selector = dict (arrowcolor = "red" ))
135+ self .assert_selected ("annotations" , [1 , 2 ], selector = dict (arrowcolor = "blue" ))
136+
114137 def test_select_annotations (self ):
115138 (
116139 self .fig .add_annotation (text = "A1" , arrowcolor = "red" )
0 commit comments