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

Skip to content

Commit c09cd9a

Browse files
authored
Merge pull request #21146 from anntzer/clim
Fix clim handling for pcolor{,mesh}.
2 parents 98d6a30 + 2d8f3be commit c09cd9a

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
@@ -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
@@ -7232,3 +7232,11 @@ def test_empty_line_plots():
72327232
_, ax = plt.subplots()
72337233
line = ax.plot([], [])
72347234
assert len(line) == 1
7235+
7236+
7237+
def test_clim():
7238+
ax = plt.figure().add_subplot()
7239+
for plot_method in [ax.imshow, ax.pcolor, ax.pcolormesh, ax.pcolorfast]:
7240+
clim = (7, 8)
7241+
norm = plot_method([[0, 1], [2, 3]], clim=clim).norm
7242+
assert (norm.vmin, norm.vmax) == clim

0 commit comments

Comments
 (0)