@@ -40,29 +40,19 @@ def test_axhspan(self):
40
40
start_date = datetime .datetime (2023 , 1 , 1 )
41
41
time_delta = datetime .timedelta (days = 1 )
42
42
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 ))
52
44
45
+ ax1 .set_ylim (start_date , start_date + 29 * time_delta )
53
46
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
56
49
ax1 .axhspan (ymin = ymin , ymax = ymax , facecolor = 'green' , alpha = 0.5 )
57
50
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 )
66
56
67
57
@pytest .mark .xfail (reason = "Test for axline not written yet" )
68
58
@mpl .style .context ("default" )
0 commit comments