There was an error while loading. Please reload this page.
2 parents 90f6a35 + a023ecf commit e67c2fbCopy full SHA for e67c2fb
2 files changed
lib/matplotlib/axes/_axes.py
@@ -2138,12 +2138,12 @@ def _convert_dx(dx, x0, xconv, convert):
2138
# removes the units from unit packages like `pint` that
2139
# wrap numpy arrays.
2140
try:
2141
- x0 = x0[0]
+ x0 = cbook.safe_first_element(x0)
2142
except (TypeError, IndexError, KeyError):
2143
x0 = x0
2144
2145
2146
- x = xconv[0]
+ x = cbook.safe_first_element(xconv)
2147
2148
x = xconv
2149
lib/matplotlib/tests/test_axes.py
@@ -1647,6 +1647,14 @@ def test_bar_pandas(pd):
1647
ax.plot(dates, baseline, color='orange', lw=4)
1648
1649
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
1658
@image_comparison(['hist_log'], remove_text=True)
1659
def test_hist_log():
1660
data0 = np.linspace(0, 1, 200)**3
0 commit comments