Skip to content

Commit 8735494

Browse files
Fix heatmap norm=None issue (#3276)
* Fix heatmap issue. * Update seaborn/matrix.py Co-authored-by: Michael Waskom <[email protected]> * Fix condition * Add test for explicit `norm=None`. --------- Co-authored-by: Michael Waskom <[email protected]>
1 parent 3733590 commit 8735494

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

seaborn/matrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def plot(self, ax, cax, kws):
298298

299299
# setting vmin/vmax in addition to norm is deprecated
300300
# so avoid setting if norm is set
301-
if "norm" not in kws:
301+
if kws.get("norm") is None:
302302
kws.setdefault("vmin", self.vmin)
303303
kws.setdefault("vmax", self.vmax)
304304

tests/test_matrix.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,20 @@ def test_cmap_with_properties(self):
265265
hm = mat._HeatMapper(self.df_unif, **kws)
266266
npt.assert_array_equal(cmap(np.inf), hm.cmap(np.inf))
267267

268+
def test_explicit_none_norm(self):
269+
270+
vals = np.linspace(.2, 1, 9)
271+
cmap = mpl.cm.binary
272+
_, (ax1, ax2) = plt.subplots(2)
273+
274+
mat.heatmap([vals], vmin=0, cmap=cmap, ax=ax1)
275+
fc_default_norm = ax1.collections[0].get_facecolors()
276+
277+
mat.heatmap([vals], vmin=0, norm=None, cmap=cmap, ax=ax2)
278+
fc_explicit_norm = ax2.collections[0].get_facecolors()
279+
280+
npt.assert_array_almost_equal(fc_default_norm, fc_explicit_norm, 2)
281+
268282
def test_ticklabels_off(self):
269283
kws = self.default_kws.copy()
270284
kws['xticklabels'] = False

0 commit comments

Comments
 (0)