From dcb48c31eaaec1c72c73ae8e9e7d1a8b23e91c1d Mon Sep 17 00:00:00 2001 From: David Stansby Date: Mon, 2 Sep 2019 09:59:52 +0100 Subject: [PATCH] Merge pull request #15166 from jklymak/fix-indexed-pandas-bar FIX: indexed pandas bar --- lib/matplotlib/axes/_axes.py | 4 ++-- lib/matplotlib/tests/test_axes.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index c14a01fa3a98..89fc3ba576d6 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2163,12 +2163,12 @@ def _convert_dx(dx, x0, xconv, convert): # removes the units from unit packages like `pint` that # wrap numpy arrays. try: - x0 = x0[0] + x0 = cbook.safe_first_element(x0) except (TypeError, IndexError, KeyError): x0 = x0 try: - x = xconv[0] + x = cbook.safe_first_element(xconv) except (TypeError, IndexError, KeyError): x = xconv diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 5cdabee201f7..8ff5ac45d27d 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -1592,6 +1592,14 @@ def test_bar_pandas(pd): ax.plot(dates, baseline, color='orange', lw=4) +def test_bar_pandas_indexed(pd): + # Smoke test for indexed pandas + df = pd.DataFrame({"x": [1., 2., 3.], "width": [.2, .4, .6]}, + index=[1, 2, 3]) + fig, ax = plt.subplots() + ax.bar(df.x, 1., width=df.width) + + @image_comparison(baseline_images=['hist_log'], remove_text=True) def test_hist_log(): 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