Skip to content

Commit 302fd39

Browse files
Added test for Axes.bar_label (#27431)
* Added test for Axes.bar_label * Added test for Axes.bar_label after fixing typos * Added test for Axes.bar_label after fixing typos * Added test for Axes.bar_label after fixing typos * Updated code based on review * Update test_datetime.py * removed the .show line and added bar_label back * added bar_label, removed show, fixed linting issues * Update lib/matplotlib/tests/test_datetime.py Changed axs to ax Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
1 parent f80ff65 commit 302fd39

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,20 @@ def test_bar(self):
163163
ax1.bar(x_dates, x_ranges, width=np.timedelta64(4, "D"))
164164
ax2.bar(np.arange(4), x_dates - x, bottom=x)
165165

166-
@pytest.mark.xfail(reason="Test for bar_label not written yet")
167166
@mpl.style.context("default")
168167
def test_bar_label(self):
169-
fig, ax = plt.subplots()
170-
ax.bar_label(...)
168+
# Generate some example data with dateTime inputs
169+
date_list = [datetime.datetime(2023, 1, 1) +
170+
datetime.timedelta(days=i) for i in range(5)]
171+
values = [10, 20, 15, 25, 30]
172+
173+
# Creating the plot
174+
fig, ax = plt.subplots(1, 1, figsize=(10, 8), layout='constrained')
175+
bars = ax.bar(date_list, values)
176+
177+
# Add labels to the bars using bar_label
178+
ax.bar_label(bars, labels=[f'{val}%' for val in values],
179+
label_type='edge', color='black')
171180

172181
@mpl.style.context("default")
173182
def test_barbs(self):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy