Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4ff96ad

Browse files
authored
Merge pull request #21149 from meeseeksmachine/auto-backport-of-pr-21146-on-v3.5.x
Backport PR #21146 on branch v3.5.x (Fix clim handling for pcolor{,mesh}.)
2 parents bf7c99b + 8183903 commit 4ff96ad

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

lib/matplotlib/axes/_axes.py

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

58425842
kwargs.setdefault('snap', False)
58435843

5844-
collection = mcoll.PolyCollection(verts, **kwargs)
5845-
5846-
collection.set_alpha(alpha)
5847-
collection.set_array(C)
5848-
collection.set_cmap(cmap)
5849-
collection.set_norm(norm)
5844+
collection = mcoll.PolyCollection(
5845+
verts, array=C, cmap=cmap, norm=norm, alpha=alpha, **kwargs)
58505846
collection._scale_norm(norm, vmin, vmax)
58515847
self._pcolor_grid_deprecation_helper()
58525848

@@ -6075,14 +6071,10 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
60756071
# convert to one dimensional array
60766072
C = C.ravel()
60776073

6078-
collection = mcoll.QuadMesh(
6079-
coords, antialiased=antialiased, shading=shading, **kwargs)
60806074
snap = kwargs.get('snap', rcParams['pcolormesh.snap'])
6081-
collection.set_snap(snap)
6082-
collection.set_alpha(alpha)
6083-
collection.set_array(C)
6084-
collection.set_cmap(cmap)
6085-
collection.set_norm(norm)
6075+
collection = mcoll.QuadMesh(
6076+
coords, antialiased=antialiased, shading=shading, snap=snap,
6077+
array=C, cmap=cmap, norm=norm, alpha=alpha, **kwargs)
60866078
collection._scale_norm(norm, vmin, vmax)
60876079
self._pcolor_grid_deprecation_helper()
60886080

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)