@@ -2334,15 +2334,24 @@ def test_grouped_bar_hatch_none():
23342334
23352335
23362336def test_grouped_bar_empty_string_disables_hatch ():
2337- """An empty string in the hatch list should result in no hatch for that dataset."""
2337+ """
2338+ Empty strings or None in the hatch list should result in no hatch
2339+ for the corresponding dataset, while valid strings should apply
2340+ the hatch pattern normally.
2341+ """
23382342 fig , ax = plt .subplots ()
23392343 x = np .arange (3 )
2340- heights = [np .array ([1 , 2 , 3 ]), np .array ([2 , 1 , 2 ])]
2341- hatches = ["" , "xx" ]
2344+ heights = [np .array ([1 , 2 , 3 ]), np .array ([2 , 1 , 2 ]), np . array ([ 3 , 2 , 1 ]) ]
2345+ hatches = ["" , "xx" , None ]
23422346 containers = ax .grouped_bar (heights , positions = x , hatch = hatches )
2347+ # Collect the hatch pattern for each bar in each dataset
23432348 counts = [[rect .get_hatch () for rect in bc ] for bc in containers .bar_containers ]
2344- assert all (h == '' or h is None for h in counts [0 ]) # first dataset: no hatch
2345- assert all (h == 'xx' for h in counts [1 ]) # second dataset: hatched
2349+ # First dataset: empty string disables hatch
2350+ assert all (h in ("" , None ) for h in counts [0 ])
2351+ # Second dataset: hatch pattern applied
2352+ assert all (h == "xx" for h in counts [1 ])
2353+ # Third dataset: None disables hatch
2354+ assert all (h in ("" , None ) for h in counts [2 ])
23462355
23472356
23482357def test_grouped_bar_dict_with_labels_forbidden ():
0 commit comments