@@ -116,11 +116,31 @@ def test_contour_manual_labels(split_collections):
116116
117117 plt .figure (figsize = (6 , 2 ), dpi = 200 )
118118 cs = plt .contour (x , y , z )
119+
120+ _maybe_split_collections (split_collections )
121+
119122 pts = np .array ([(1.0 , 3.0 ), (1.0 , 4.4 ), (1.0 , 6.0 )])
120123 plt .clabel (cs , manual = pts )
121124 pts = np .array ([(2.0 , 3.0 ), (2.0 , 4.4 ), (2.0 , 6.0 )])
122125 plt .clabel (cs , manual = pts , fontsize = 'small' , colors = ('r' , 'g' ))
123126
127+
128+ @pytest .mark .parametrize ("split_collections" , [False , True ])
129+ @image_comparison (['contour_disconnected_segments' ],
130+ remove_text = True , style = 'mpl20' , extensions = ['png' ])
131+ def test_contour_label_with_disconnected_segments (split_collections ):
132+ x , y = np .mgrid [- 1 :1 :21j , - 1 :1 :21j ]
133+ z = 1 / np .sqrt (0.01 + (x + 0.3 ) ** 2 + y ** 2 )
134+ z += 1 / np .sqrt (0.01 + (x - 0.3 ) ** 2 + y ** 2 )
135+
136+ plt .figure ()
137+ cs = plt .contour (x , y , z , levels = [7 ])
138+
139+ # Adding labels should invalidate the old style
140+ _maybe_split_collections (split_collections )
141+
142+ cs .clabel (manual = [(0.2 , 0.1 )])
143+
124144 _maybe_split_collections (split_collections )
125145
126146
@@ -232,6 +252,9 @@ def test_labels(split_collections):
232252 disp_units = [(216 , 177 ), (359 , 290 ), (521 , 406 )]
233253 data_units = [(- 2 , .5 ), (0 , - 1.5 ), (2.8 , 1 )]
234254
255+ # Adding labels should invalidate the old style
256+ _maybe_split_collections (split_collections )
257+
235258 CS .clabel ()
236259
237260 for x , y in data_units :
0 commit comments