Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bf0ca5a

Browse filesBrowse files
committed
Merge pull request #5206 from WeatherGod/fix_5205
FIX: Apply asanyarray to arguments for pcolor and family
2 parents 2c00342 + df6e1ac commit bf0ca5a
Copy full SHA for bf0ca5a

File tree

2 files changed

+17
-2
lines changed
Filter options

2 files changed

+17
-2
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4977,7 +4977,7 @@ def _pcolorargs(funcname, *args, **kw):
49774977
allmatch = kw.pop("allmatch", False)
49784978

49794979
if len(args) == 1:
4980-
C = args[0]
4980+
C = np.asanyarray(args[0])
49814981
numRows, numCols = C.shape
49824982
if allmatch:
49834983
X, Y = np.meshgrid(np.arange(numCols), np.arange(numRows))
@@ -4987,7 +4987,7 @@ def _pcolorargs(funcname, *args, **kw):
49874987
return X, Y, C
49884988

49894989
if len(args) == 3:
4990-
X, Y, C = args
4990+
X, Y, C = [np.asanyarray(a) for a in args]
49914991
numRows, numCols = C.shape
49924992
else:
49934993
raise TypeError(

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,21 @@ def test_symlog2():
738738
ax.set_ylim(-0.1, 0.1)
739739

740740

741+
@cleanup
742+
def test_pcolorargs():
743+
# Smoketest to catch issue found in gh:5205
744+
x = [-1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5]
745+
y = [-1.5, -1.25, -1.0, -0.75, -0.5, -0.25, 0,
746+
0.25, 0.5, 0.75, 1.0, 1.25, 1.5]
747+
X, Y = np.meshgrid(x, y)
748+
Z = np.hypot(X, Y)
749+
750+
plt.pcolor(Z)
751+
plt.pcolor(list(Z))
752+
plt.pcolor(x, y, Z)
753+
plt.pcolor(X, Y, list(Z))
754+
755+
741756
@image_comparison(baseline_images=['pcolormesh'], remove_text=True)
742757
def test_pcolormesh():
743758
n = 12

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.