From df6e1accbd57ee6f44ae01edc7134069939f0b0a Mon Sep 17 00:00:00 2001 From: Benjamin Root Date: Wed, 7 Oct 2015 15:11:24 -0400 Subject: [PATCH] Apply asanyarray to arguments for pcolor and family --- lib/matplotlib/axes/_axes.py | 4 ++-- lib/matplotlib/tests/test_axes.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 97e5e55d90ac..e9f0c9b75893 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4982,7 +4982,7 @@ def _pcolorargs(funcname, *args, **kw): allmatch = kw.pop("allmatch", False) if len(args) == 1: - C = args[0] + C = np.asanyarray(args[0]) numRows, numCols = C.shape if allmatch: X, Y = np.meshgrid(np.arange(numCols), np.arange(numRows)) @@ -4992,7 +4992,7 @@ def _pcolorargs(funcname, *args, **kw): return X, Y, C if len(args) == 3: - X, Y, C = args + X, Y, C = [np.asanyarray(a) for a in args] numRows, numCols = C.shape else: raise TypeError( diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index f254e17b7449..ca0bd494a5d0 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -738,6 +738,21 @@ def test_symlog2(): ax.set_ylim(-0.1, 0.1) +@cleanup +def test_pcolorargs(): + # Smoketest to catch issue found in gh:5205 + x = [-1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5] + y = [-1.5, -1.25, -1.0, -0.75, -0.5, -0.25, 0, + 0.25, 0.5, 0.75, 1.0, 1.25, 1.5] + X, Y = np.meshgrid(x, y) + Z = np.hypot(X, Y) + + plt.pcolor(Z) + plt.pcolor(list(Z)) + plt.pcolor(x, y, Z) + plt.pcolor(X, Y, list(Z)) + + @image_comparison(baseline_images=['pcolormesh'], remove_text=True) def test_pcolormesh(): n = 12