From 7f8290ea681c13addcaf987e8541395458a51115 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Sat, 9 Feb 2019 18:16:20 -0800 Subject: [PATCH 1/3] FIX: let pandas IndexInt64 work for boxplot --- lib/matplotlib/axes/_axes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 7f7290c6e502..730658aa1db7 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3925,6 +3925,7 @@ def dopatch(xs, ys, **kwargs): positions = list(range(1, N + 1)) elif len(positions) != N: raise ValueError(datashape_message.format("positions")) + positions = np.array(positions) # width if widths is None: From d1999b279f8780b0f96b7fabdbe66126849c6f49 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Sat, 9 Feb 2019 19:27:51 -0800 Subject: [PATCH 2/3] TST: add smoketest --- lib/matplotlib/tests/test_axes.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 40c23f6c5967..2dbb3c2fba6c 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -1524,6 +1524,15 @@ def test_bar_timedelta(): (10, 20)) +def test_boxplot_dates_pandas(pd): + # smoke test for boxplot and dates in pandas + data = np.random.rand(5, 2) + years = pd.date_range('1/1/2000', + periods=2, freq=pd.DateOffset(years=1)).year + plt.figure() + plt.boxplot(data, positions=years) + + def test_bar_pandas(pd): # Smoke test for pandas From 728106a38b383330c300e38ed44e8a9d2bfa48e0 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Sun, 10 Feb 2019 14:07:06 -0800 Subject: [PATCH 3/3] MNT: add error check if not a number --- lib/matplotlib/axes/_axes.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 730658aa1db7..786b8892b8d4 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3925,7 +3925,10 @@ def dopatch(xs, ys, **kwargs): positions = list(range(1, N + 1)) elif len(positions) != N: raise ValueError(datashape_message.format("positions")) + positions = np.array(positions) + if len(positions) > 0 and not isinstance(positions[0], Number): + raise TypeError("positions should be an iterable of numbers") # width if widths is None: