Skip to content

Commit d9aac95

Browse files
committed
added test for CenteredNorm, bugfix related to #19972
1 parent d1b112c commit d9aac95

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/matplotlib/colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ def autoscale(self, A):
13841384
def autoscale_None(self, A):
13851385
"""Set *vmin* and *vmax*."""
13861386
A = np.asanyarray(A)
1387-
if self.vmax is None and A.size:
1387+
if self._halfrange is None and A.size:
13881388
self.autoscale(A)
13891389

13901390
@property

lib/matplotlib/tests/test_colors.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,12 @@ def test_CenteredNorm():
418418
norm.autoscale_None([1, 2])
419419
assert norm.vmax + norm.vmin == 2 * vcenter
420420

421+
# Check that halfrange can be set without setting vcenter and that it is
422+
# not reset through autoscale_None.
423+
norm = mcolors.CenteredNorm(halfrange=1.0)
424+
norm.autoscale_None([1, 3000])
425+
assert norm.halfrange == 1.0
426+
421427
# Check that halfrange input works correctly.
422428
x = np.random.normal(size=10)
423429
norm = mcolors.CenteredNorm(vcenter=0.5, halfrange=0.5)

0 commit comments

Comments
 (0)