From 81839037518a6d709b160498bc9559ea82f67596 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Wed, 22 Sep 2021 13:33:30 +0200 Subject: [PATCH] Backport PR #21146: Fix clim handling for pcolor{,mesh}. --- lib/matplotlib/axes/_axes.py | 18 +++++------------- lib/matplotlib/tests/test_axes.py | 8 ++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index cef0f8c3c88d..f9b63e4d85c7 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -5845,12 +5845,8 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None, kwargs.setdefault('snap', False) - collection = mcoll.PolyCollection(verts, **kwargs) - - collection.set_alpha(alpha) - collection.set_array(C) - collection.set_cmap(cmap) - collection.set_norm(norm) + collection = mcoll.PolyCollection( + verts, array=C, cmap=cmap, norm=norm, alpha=alpha, **kwargs) collection._scale_norm(norm, vmin, vmax) self._pcolor_grid_deprecation_helper() @@ -6079,14 +6075,10 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None, # convert to one dimensional array C = C.ravel() - collection = mcoll.QuadMesh( - coords, antialiased=antialiased, shading=shading, **kwargs) snap = kwargs.get('snap', rcParams['pcolormesh.snap']) - collection.set_snap(snap) - collection.set_alpha(alpha) - collection.set_array(C) - collection.set_cmap(cmap) - collection.set_norm(norm) + collection = mcoll.QuadMesh( + coords, antialiased=antialiased, shading=shading, snap=snap, + array=C, cmap=cmap, norm=norm, alpha=alpha, **kwargs) collection._scale_norm(norm, vmin, vmax) self._pcolor_grid_deprecation_helper() diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 6067d54cf517..59ebc2c2f53d 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -7225,3 +7225,11 @@ def test_empty_line_plots(): _, ax = plt.subplots() line = ax.plot([], []) assert len(line) == 1 + + +def test_clim(): + ax = plt.figure().add_subplot() + for plot_method in [ax.imshow, ax.pcolor, ax.pcolormesh, ax.pcolorfast]: + clim = (7, 8) + norm = plot_method([[0, 1], [2, 3]], clim=clim).norm + assert (norm.vmin, norm.vmax) == clim 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