8000 Merge pull request #1362 from Tillsten/lognormfix · matplotlib/matplotlib@9d2e515 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9d2e515

Browse files
committed
Merge pull request #1362 from Tillsten/lognormfix
fixed lognorm clip behavior
2 parents bb3ea55 + adb1be2 commit 9d2e515

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/matplotlib/colors.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 9 additions & 0 deletions
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)
0