Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ea8f80a

Browse files
committed
FIX: image respect norm limits w/ None
1 parent 834cfc8 commit ea8f80a

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

lib/matplotlib/image.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -390,22 +390,24 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
390390
# float64's ability to represent changes. Applying
391391
# a norm first would be good, but ruins the interpolation
392392
# of over numbers.
393-
if self.norm.vmin is not None and self.norm.vmax is not None:
394-
dv = (np.float64(self.norm.vmax) -
395-
np.float64(self.norm.vmin))
396-
vmid = self.norm.vmin + dv / 2
397-
newmin = vmid - dv * 1.e7
398-
if newmin < a_min:
399-
newmin = None
400-
else:
401-
a_min = np.float64(newmin)
402-
newmax = vmid + dv * 1.e7
403-
if newmax > a_max:
404-
newmax = None
405-
else:
406-
a_max = np.float64(newmax)
407-
if newmax is not None or newmin is not None:
408-
A_scaled = np.clip(A_scaled, newmin, newmax)
393+
vmin = self.norm.vmin if self.norm.vmin is not None else a_min
394+
vmax = self.norm.vmax if self.norm.vmax is not None else a_max
395+
396+
dv = (np.float64(vmax) -
397+
np.float64(vmin))
398+
vmid = vmin + dv / 2
399+
newmin = vmid - dv * 1.e7
400+
if newmin < a_min:
401+
newmin = None
402+
else:
403+
a_min = np.float64(newmin)
404+
newmax = vmid + dv * 1.e7
405+
if newmax > a_max:
406+
newmax = None
407+
else:
408+
a_max = np.float64(newmax)
409+
if newmax is not None or newmin is not None:
410+
A_scaled = np.clip(A_scaled, newmin, newmax)
409411

410412
A_scaled -= a_min
411413
# a_min and a_max might be ndarray subclasses so use

0 commit comments

Comments
 (0)