Thanks to visit codestin.com
Credit goes to github.com

Skip to content
15 changes: 12 additions & 3 deletions lib/matplotlib/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down