diff --git a/doc/api/next_api_changes/deprecations/20237-TH.rst b/doc/api/next_api_changes/deprecations/20237-TH.rst index 2120fb9b9bef..435986f94f0f 100644 --- a/doc/api/next_api_changes/deprecations/20237-TH.rst +++ b/doc/api/next_api_changes/deprecations/20237-TH.rst @@ -3,11 +3,11 @@ QuadMesh signature The ``QuadMesh`` signature :: def __init__(meshWidth, meshHeight, coordinates, - antialiased=True, shading=False, **kwargs) + antialiased=True, shading='flat', **kwargs) is deprecated and replaced by the new signature :: - def __init__(coordinates, *, antialiased=True, shading=False, **kwargs) + def __init__(coordinates, *, antialiased=True, shading='flat', **kwargs) In particular: diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index 1f88bbef3e4f..ee9058e9f52a 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -2002,7 +2002,7 @@ def __init__(self, *args, **kwargs): # The following raises a TypeError iif the args don't match. w, h, coords, antialiased, shading, kwargs = ( lambda meshWidth, meshHeight, coordinates, antialiased=True, - shading=False, **kwargs: + shading='flat', **kwargs: (meshWidth, meshHeight, coordinates, antialiased, shading, kwargs))(*args, **kwargs) except TypeError as exc: @@ -2010,7 +2010,7 @@ def __init__(self, *args, **kwargs): # If the following raises a TypeError (i.e. args don't match), # just let it propagate. coords, antialiased, shading, kwargs = ( - lambda coordinates, antialiased=True, shading=False, **kwargs: + lambda coordinates, antialiased=True, shading='flat', **kwargs: (coordinates, antialiased, shading, kwargs))(*args, **kwargs) coords = np.asarray(coords, np.float64) else: # The old signature matched. diff --git a/lib/matplotlib/tests/test_collections.py b/lib/matplotlib/tests/test_collections.py index 12d26752f80f..3a12f2fc3fc1 100644 --- a/lib/matplotlib/tests/test_collections.py +++ b/lib/matplotlib/tests/test_collections.py @@ -743,6 +743,7 @@ def test_quadmesh_deprecated_signature( qmesh = QuadMesh(coords, **kwargs) qmesh.set_array(C) ax.add_collection(qmesh) + assert qmesh._shading == 'flat' ax = fig_ref.add_subplot() ax.set(xlim=(0, 5), ylim=(0, 4)) @@ -754,6 +755,7 @@ def test_quadmesh_deprecated_signature( **kwargs) qmesh.set_array(C.flatten() if flat_ref else C) ax.add_collection(qmesh) + assert qmesh._shading == 'flat' @check_figures_equal(extensions=['png'])