Skip to content

Commit bf2af86

Browse files
authored
Merge pull request #25070 from meeseeksmachine/auto-backport-of-pr-25058-on-v3.7.x
Backport PR #25058 on branch v3.7.x (fix for pcolormesh doesn't allow shading = 'flat' in the option)
2 parents f06f866 + fb4a40c commit bf2af86

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/matplotlib/axes/_axes.py

Lines 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

Lines 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy