There was an error while loading. Please reload this page.
2 parents f588373 + dcb48c3 commit 169a9f7Copy full SHA for 169a9f7
2 files changed
lib/matplotlib/axes/_axes.py
@@ -2163,12 +2163,12 @@ def _convert_dx(dx, x0, xconv, convert):
2163
# removes the units from unit packages like `pint` that
2164
# wrap numpy arrays.
2165
try:
2166
- x0 = x0[0]
+ x0 = cbook.safe_first_element(x0)
2167
except (TypeError, IndexError, KeyError):
2168
x0 = x0
2169
2170
2171
- x = xconv[0]
+ x = cbook.safe_first_element(xconv)
2172
2173
x = xconv
2174
lib/matplotlib/tests/test_axes.py
@@ -1592,6 +1592,14 @@ def test_bar_pandas(pd):
1592
ax.plot(dates, baseline, color='orange', lw=4)
1593
1594
1595
+def test_bar_pandas_indexed(pd):
1596
+ # Smoke test for indexed pandas
1597
+ df = pd.DataFrame({"x": [1., 2., 3.], "width": [.2, .4, .6]},
1598
+ index=[1, 2, 3])
1599
+ fig, ax = plt.subplots()
1600
+ ax.bar(df.x, 1., width=df.width)
1601
+
1602
1603
@image_comparison(baseline_images=['hist_log'],
1604
remove_text=True)
1605
def test_hist_log():
0 commit comments