8000 Avoid warning on nan input to log-scaled plots. · matplotlib/matplotlib@63af7a7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 63af7a7

Browse files
committed
Avoid warning on nan input to log-scaled plots.
1 parent 7a6ad6a commit 63af7a7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/matplotlib/scale.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ def __init__(self, nonpos):
9898
self._fill_value = 1e-300
9999

100100
def transform_non_affine(self, a):
101-
a = np.where(a <= 0, self._fill_value, a)
101+
with np.errstate(invalid="ignore"):
102+
a = np.where(a <= 0, self._fill_value, a)
102103
np.log(a, a)
103104
a /= np.log(self.base)
104105
a += 1
@@ -435,8 +436,9 @@ def __init__(self, nonpos):
435436

436437
def transform_non_affine(self, a):
437438
"""logit transform (base 10), masked or clipped"""
438-
a = np.select(
439-
[a <= 0, a >= 1], [self._fill_value, 1 - self._fill_value], a)
439+
with np.errstate(invalid="ignore"):
440+
a = np.select(
441+
[a <= 0, a >= 1], [self._fill_value, 1 - self._fill_value], a)
440442
return np.log10(1.0 * a / (1.0 - a))
441443

442444
def inverted(self):

0 commit comments

Comments
 (0)
0