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 e67c2fb

Browse filesBrowse files
authored
Merge pull request #15166 from jklymak/fix-indexed-pandas-bar
FIX: indexed pandas bar
2 parents 90f6a35 + a023ecf commit e67c2fb
Copy full SHA for e67c2fb

File tree

Expand file treeCollapse file tree

2 files changed

+10
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-2
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,12 +2138,12 @@ def _convert_dx(dx, x0, xconv, convert):
21382138
# removes the units from unit packages like `pint` that
21392139
# wrap numpy arrays.
21402140
try:
2141-
x0 = x0[0]
2141+
x0 = cbook.safe_first_element(x0)
21422142
except (TypeError, IndexError, KeyError):
21432143
x0 = x0
21442144

21452145
try:
2146-
x = xconv[0]
2146+
x = cbook.safe_first_element(xconv)
21472147
except (TypeError, IndexError, KeyError):
21482148
x = xconv
21492149

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,14 @@ def test_bar_pandas(pd):
16471647
ax.plot(dates, baseline, color='orange', lw=4)
16481648

16491649

1650+
def test_bar_pandas_indexed(pd):
1651+
# Smoke test for indexed pandas
1652+
df = pd.DataFrame({"x": [1., 2., 3.], "width": [.2, .4, .6]},
1653+
index=[1, 2, 3])
1654+
fig, ax = plt.subplots()
1655+
ax.bar(df.x, 1., width=df.width)
1656+
1657+
16501658
@image_comparison(['hist_log'], remove_text=True)
16511659
def test_hist_log():
16521660
data0 = np.linspace(0, 1, 200)**3

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.