Skip to content

Commit 8183903

Browse files
timhoffmmeeseeksmachine
authored andcommitted
Backport PR matplotlib#21146: Fix clim handling for pcolor{,mesh}.
1 parent 286d0d4 commit 8183903

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

lib/matplotlib/axes/_axes.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5845,12 +5845,8 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
58455845

58465846
kwargs.setdefault('snap', False)
58475847

5848-
collection = mcoll.PolyCollection(verts, **kwargs)
5849-
5850-
collection.set_alpha(alpha)
5851-
collection.set_array(C)
5852-
collection.set_cmap(cmap)
5853-
collection.set_norm(norm)
5848+
collection = mcoll.PolyCollection(
5849+
verts, array=C, cmap=cmap, norm=norm, alpha=alpha, **kwargs)
58545850
collection._scale_norm(norm, vmin, vmax)
58555851
self._pcolor_grid_deprecation_helper()
58565852

@@ -6079,14 +6075,10 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
60796075
# convert to one dimensional array
60806076
C = C.ravel()
60816077

6082-
collection = mcoll.QuadMesh(
6083-
coords, antialiased=antialiased, shading=shading, **kwargs)
60846078
snap = kwargs.get('snap', rcParams['pcolormesh.snap'])
6085-
collection.set_snap(snap)
6086-
collection.set_alpha(alpha)
6087-
collection.set_array(C)
6088-
collection.set_cmap(cmap)
6089-
collection.set_norm(norm)
6079+
collection = mcoll.QuadMesh(
6080+
coords, antialiased=antialiased, shading=shading, snap=snap,
6081+
array=C, cmap=cmap, norm=norm, alpha=alpha, **kwargs)
60906082
collection._scale_norm(norm, vmin, vmax)
60916083
self._pcolor_grid_deprecation_helper()
60926084

lib/matplotlib/tests/test_axes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7225,3 +7225,11 @@ def test_empty_line_plots():
72257225
_, ax = plt.subplots()
72267226
line = ax.plot([], [])
72277227
assert len(line) == 1
7228+
7229+
7230+
def test_clim():
7231+
ax = plt.figure().add_subplot()
7232+
for plot_method in [ax.imshow, ax.pcolor, ax.pcolormesh, ax.pcolorfast]:
7233+
clim = (7, 8)
7234+
norm = plot_method([[0, 1], [2, 3]], clim=clim).norm
7235+
assert (norm.vmin, norm.vmax) == clim

0 commit comments

Comments
 (0)