Skip to content

Commit adb1be2

Browse files
committed
fixed lognorm clip behavior
added test
1 parent bb3ea55 commit adb1be2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/matplotlib/colors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ def __call__(self, value, clip=None):
953953
else:
954954
if clip:
955955
mask = ma.getmask(result)
956-
val = ma.array(np.clip(result.filled(vmax), vmin, vmax),
956+
result = ma.array(np.clip(result.filled(vmax), vmin, vmax),
957957
mask=mask)
958958
# in-place equivalent of above can be much faster
959959
resdat = result.data

lib/matplotlib/tests/test_colors.py

+9
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,13 @@ def test_BoundaryNorm():
3636
ncolors = len(boundaries)
3737
bn = mcolors.BoundaryNorm(boundaries, ncolors)
3838
assert_array_equal(bn(vals), expected)
39+
40+
def test_LogNorm():
41+
"""
42+
LogNorm igornoed clip, now it has the same
43+
behavior as Normalize, e.g. values > vmax are bigger than 1
44+
without clip, with clip they are 1.
45+
"""
46+
ln = mcolors.LogNorm(clip=True, vmax=5)
47+
assert_array_equal(ln([1, 6]), [0, 1.0])
3948

0 commit comments

Comments
 (0)