@@ -40,29 +40,19 @@ def test_axhspan(self):
4040 start_date = datetime .datetime (2023 , 1 , 1 )
4141 time_delta = datetime .timedelta (days = 1 )
4242
43- values = np .random .randint (1 , 10 , 30 )
44- bin_edges = [start_date + i * time_delta for i in range (31 )]
45-
46- fig , (ax1 , ax2 ) = plt .subplots (2 , 1 , constrained_layout = True )
47-
48- ax1 .hist (
49- [start_date + i * time_delta for i in range (30 )],
50- bins = bin_edges ,
51- weights = values )
43+ fig , (ax1 , ax2 ) = plt .subplots (2 , 1 , constrained_layout = True , figsize = (10 , 8 ))
5244
45+ ax1 .set_ylim (start_date , start_date + 29 * time_delta )
5346 for i in range (np .random .randint (1 , 5 )):
54- ymin = np .random .randint (1 , 8 )
55- ymax = ymin + np .random .randint (1 , 3 )
47+ ymin = start_date + np .random .randint (0 , 30 ) * time_delta
48+ ymax = ymin + np .random .randint (1 , 3 ) * time_delta
5649 ax1 .axhspan (ymin = ymin , ymax = ymax , facecolor = 'green' , alpha = 0.5 )
5750
58- ax2 .hist (
59- [start_date + i * time_delta for i in range (30 )],
60- bins = bin_edges ,
61- weights = values )
62-
63- y_values = np .unique (values )
64- for i , y in enumerate (y_values [::2 ]):
65- ax2 .axhspan (ymin = y , ymax = y + 1 , facecolor = 'green' , alpha = 0.5 )
51+ ax2 .set_ylim (start_date , start_date + 29 * time_delta )
52+ for i in range (0 , 30 , 2 ):
53+ ymin = start_date + i * time_delta
54+ ymax = ymin + time_delta
55+ ax2 .axhspan (ymin = ymin , ymax = ymax , facecolor = 'green' , alpha = 0.5 )
6656
6757 @pytest .mark .xfail (reason = "Test for axline not written yet" )
6858 @mpl .style .context ("default" )
0 commit comments