Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 302fd39

Browse filesBrowse 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
Copy full SHA for 302fd39

File tree

Expand file treeCollapse file tree

1 file changed

+12
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-3
lines changed

‎lib/matplotlib/tests/test_datetime.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_datetime.py
+12-3Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.