From 11b619c157cfe7246f6fb2645bdaa159c22f304a Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Thu, 7 Sep 2017 21:09:19 -0700 Subject: [PATCH 1/3] Fix pcolormesh and DatetimeIndex error --- lib/matplotlib/axes/_axes.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 402382587ccf..48126b6be55e 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -5620,7 +5620,8 @@ def pcolormesh(self, *args, **kwargs): X, Y, C = self._pcolorargs('pcolormesh', *args, allmatch=allmatch) Ny, Nx = X.shape - + X = X.ravel() + Y = Y.ravel() # unit conversion allows e.g. datetime objects as axis values self._process_unit_info(xdata=X, ydata=Y, kwargs=kwargs) X = self.convert_xunits(X) @@ -5628,7 +5629,7 @@ def pcolormesh(self, *args, **kwargs): # convert to one dimensional arrays C = C.ravel() - coords = np.column_stack((X.flat, Y.flat)).astype(float, copy=False) + coords = np.column_stack((X, Y)).astype(float, copy=False) collection = mcoll.QuadMesh(Nx - 1, Ny - 1, coords, antialiased=antialiased, shading=shading, From e12db84a50fb9742eda5a50f7ca8e2f8609b3b49 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Mon, 18 Sep 2017 15:24:19 -0400 Subject: [PATCH 2/3] TST: add test for pandas + pcolormesh --- lib/matplotlib/tests/test_axes.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index b96b525aa439..108eea4b7068 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -4929,6 +4929,17 @@ def test_broken_barh_empty(): ax.broken_barh([], (.1, .5)) +def test_pandas_pcolormesh(): + pd = pytest.importorskip('pandas') + + time = pd.date_range('2000-01-01', periods=10) + depth = np.arange(20) + data = np.random.rand(20,10) + + fig, ax = plt.subplots() + ax.pcolormesh(time, depth, data) + + def test_pandas_indexing_dates(): pd = pytest.importorskip('pandas') From a473231b5afb4ec32c23d834ac86ce5ecd96856b Mon Sep 17 00:00:00 2001 From: Eric Firing Date: Tue, 19 Sep 2017 21:01:18 -1000 Subject: [PATCH 3/3] PEP-8: add space after comma in test --- lib/matplotlib/tests/test_axes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 108eea4b7068..25a4fff43edc 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -4934,7 +4934,7 @@ def test_pandas_pcolormesh(): time = pd.date_range('2000-01-01', periods=10) depth = np.arange(20) - data = np.random.rand(20,10) + data = np.random.rand(20, 10) fig, ax = plt.subplots() ax.pcolormesh(time, depth, data)