diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index ca8e1cb90732..9eb46bb32fe4 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -140,11 +140,20 @@ def test_bar(self): fig, ax = plt.subplots() ax.bar(...) - @pytest.mark.xfail(reason="Test for bar_label not written yet") @mpl.style.context("default") def test_bar_label(self): - fig, ax = plt.subplots() - ax.bar_label(...) + # Generate some example data with dateTime inputs + date_list = [datetime.datetime(2023, 1, 1) + + datetime.timedelta(days=i) for i in range(5)] + values = [10, 20, 15, 25, 30] + + # Creating the plot + fig, ax = plt.subplots(1, 1, figsize=(10, 8), layout='constrained') + bars = ax.bar(date_list, values) + + # Add labels to the bars using bar_label + ax.bar_label(bars, labels=[f'{val}%' for val in values], + label_type='edge', color='black') @mpl.style.context("default") def test_barbs(self):