@@ -77,17 +77,21 @@ def test_barbs(self):
77
77
@mpl .style .context ("default" )
78
78
def test_barh (self ):
79
79
mpl .rcParams ["date.converter" ] = 'concise'
80
- N = 14
81
- base = datetime .datetime (1970 , 1 , 1 )
82
- indices = np .arange (N )
83
- dates = [base + datetime .timedelta (days = (7 * i )) for i in range (N )]
84
- widths = [datetime .timedelta (days = (7 * i )) for i in range (N )]
85
- fig , (ax1 , ax2 , ax3 , ax4 ) = plt .subplots (4 , 1 , layout = 'constrained' )
86
- error = np .random .rand (N )
87
- ax1 .barh (indices , dates , xerr = error )
88
- ax2 .barh (dates , indices )
89
- ax3 .barh (dates , dates )
90
- ax4 .barh (indices , width = widths , left = base )
80
+ fig , (ax1 , ax2 ) = plt .subplots (2 , 1 , layout = 'constrained' )
81
+ birth_date = np .array ([datetime .datetime (2020 , 4 , 10 ),
82
+ datetime .datetime (2020 , 5 , 30 ),
83
+ datetime .datetime (2020 , 10 , 12 ),
84
+ datetime .datetime (2020 , 11 , 15 )])
85
+ year_start = datetime .datetime (2020 , 1 , 1 )
86
+ year_end = datetime .datetime (2020 , 12 , 31 )
87
+ age = [21 , 53 , 20 , 24 ]
88
+ ax1 .set_xlabel ('Age' )
89
+ ax1 .set_ylabel ('Birth Date' )
90
+ ax1 .barh (birth_date , width = age , height = datetime .timedelta (days = 10 ))
91
+ ax2 .set_xlim (left = year_start , right = year_end )
92
+ ax2 .set_xlabel ('Birth Date' )
93
+ ax2 .set_ylabel ('Order of Birth Dates' )
94
+ ax2 .barh (np .arange (4 ), birth_date - year_start , left = year_start )
91
95
92
96
@pytest .mark .xfail (reason = "Test for boxplot not written yet" )
93
97
@mpl .style .context ("default" )
0 commit comments