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 0ec308d

Browse filesBrowse files
authored
Merge pull request #25058 from vivekvedant/fix-pcolormesh-issue
fix for pcolormesh doesn't allow shading = 'flat' in the option
2 parents bf77d68 + ad06d93 commit 0ec308d
Copy full SHA for 0ec308d

File tree

Expand file treeCollapse file tree

2 files changed

+12
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-3
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5748,9 +5748,10 @@ def _pcolorargs(self, funcname, *args, shading='auto', **kwargs):
57485748

57495749
if shading == 'flat':
57505750
if (Nx, Ny) != (ncols + 1, nrows + 1):
5751-
raise TypeError('Dimensions of C %s are incompatible with'
5752-
' X (%d) and/or Y (%d); see help(%s)' % (
5753-
C.shape, Nx, Ny, funcname))
5751+
raise TypeError(f"Dimensions of C {C.shape} should"
5752+
f" be one smaller than X({Nx}) and Y({Ny})"
5753+
f" while using shading='flat'"
5754+
f" see help({funcname})")
57545755
else: # ['nearest', 'gouraud']:
57555756
if (Nx, Ny) != (ncols, nrows):
57565757
raise TypeError('Dimensions of C %s are incompatible with'

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,14 @@ def test_pcolorflaterror():
14391439
ax.pcolormesh(x, y, Z, shading='flat')
14401440

14411441

1442+
def test_samesizepcolorflaterror():
1443+
fig, ax = plt.subplots()
1444+
x, y = np.meshgrid(np.arange(5), np.arange(3))
1445+
Z = x + y
1446+
with pytest.raises(TypeError, match=r".*one smaller than X"):
1447+
ax.pcolormesh(x, y, Z, shading='flat')
1448+
1449+
14421450
@pytest.mark.parametrize('snap', [False, True])
14431451
@check_figures_equal(extensions=["png"])
14441452
def test_pcolorauto(fig_test, fig_ref, snap):

0 commit comments

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