From 7eb0b51fc5b5c0fcb35dcc946c675f8eab647035 Mon Sep 17 00:00:00 2001 From: Gabriel Silva Date: Thu, 21 May 2026 20:32:23 +0100 Subject: [PATCH 1/2] DOC: Correct exception type for invalid X,Y shapes pcolor and pcolormesh raise TypeError for incompatible grid and data dimensions. --- lib/matplotlib/axes/_axes.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index dd1eb8433888..f631110f0b53 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -6617,11 +6617,11 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None, :ref:`Notes ` section below. If ``shading='flat'`` the dimensions of *X* and *Y* should be one - greater than those of *C*, otherwise a ValueError is raised. The + greater than those of *C*, otherwise a TypeError is raised. The quadrilateral is colored due to the value at ``C[i, j]``. If ``shading='nearest'``, the dimensions of *X* and *Y* should be - the same as those of *C* (if not, a ValueError will be raised). The + the same as those of *C* (if not, a TypeError will be raised). The color ``C[i, j]`` will be centered on ``(X[i, j], Y[i, j])``. If *X* and/or *Y* are 1-D arrays or column vectors they will be @@ -6822,11 +6822,11 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None, :ref:`Notes ` section below. If ``shading='flat'`` the dimensions of *X* and *Y* should be one - greater than those of *C*, otherwise a ValueError is raised. The + greater than those of *C*, otherwise a TypeError is raised. The quadrilateral is colored due to the value at ``C[i, j]``. If ``shading='nearest'`` or ``'gouraud'``, the dimensions of *X* - and *Y* should be the same as those of *C* (if not, a ValueError + and *Y* should be the same as those of *C* (if not, a TypeError will be raised). For ``'nearest'`` the color ``C[i, j]`` is centered on ``(X[i, j], Y[i, j])``. For ``'gouraud'``, a smooth interpolation is carried out between the quadrilateral corners. From f5b6b895494e9258860bda5cc5180db01de32590 Mon Sep 17 00:00:00 2001 From: Gabriel Silva Date: Thu, 21 May 2026 20:40:09 +0100 Subject: [PATCH 2/2] DOC: Remove 'flat' shading deprecation note When X, Y, C have the same shape, the last row/column of C is no longer dropped with a deprecation warning (a TypeError is raised instead). --- lib/matplotlib/axes/_axes.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index f631110f0b53..f7e9edc73ebf 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -6634,9 +6634,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None, - 'flat': A solid color is used for each quad. The color of the quad (i, j), (i+1, j), (i, j+1), (i+1, j+1) is given by ``C[i, j]``. The dimensions of *X* and *Y* should be - one greater than those of *C*; if they are the same as *C*, - then a deprecation warning is raised, and the last row - and column of *C* are dropped. + one greater than those of *C*. - 'nearest': Each grid point will have a color centered on it, extending halfway between the adjacent grid centers. The dimensions of *X* and *Y* must be the same as *C*. @@ -6864,9 +6862,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None, - 'flat': A solid color is used for each quad. The color of the quad (i, j), (i+1, j), (i, j+1), (i+1, j+1) is given by ``C[i, j]``. The dimensions of *X* and *Y* should be - one greater than those of *C*; if they are the same as *C*, - then a deprecation warning is raised, and the last row - and column of *C* are dropped. + one greater than those of *C*. - 'nearest': Each grid point will have a color centered on it, extending halfway between the adjacent grid centers. The dimensions of *X* and *Y* must be the same as *C*.