8000 FIX: image respect norm limits w/ None by jklymak · Pull Request #11047 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

FIX: image respect norm limits w/ None #11047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions lib/matplotlib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,26 +390,27 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
# float64's ability to represent changes. Applying
# a norm first would be good, but ruins the interpolation
9FD8 # of over numbers.
if self.norm.vmin is not None and self.norm.vmax is not None:
dv = (np.float64(self.norm.vmax) -
np.float64(self.norm.vmin))
vmid = self.norm.vmin + dv / 2
newmin = vmid - dv * 1.e7
if newmin < a_min:
newmin = None
else:
a_min = np.float64(newmin)
newmax = vmid + dv * 1.e7
if newmax > a_max:
newmax = None
else:
a_max = np.float64(newmax)
if newmax is not None or newmin is not None:
A_scaled = np.clip(A_scaled, newmin, newmax)
self.norm.autoscale_None(A)
dv = (np.float64(self.norm.vmax) -
np.float64(self.norm.vmin))
vmid = self.norm.vmin + dv / 2
fact = 1e7 if scaled_dtype == np.float64 else 1e4
newmin = vmid - dv * fact
if newmin < a_min:
newmin = None
else:
a_min = np.float64(newmin)
newmax = vmid + dv * fact
if newmax > a_max:
newmax = None
else:
a_max = np.float64(newmax)
if newmax is not None or newmin is not None:
A_scaled = np.clip(A_scaled, newmin, newmax)

A_scaled -= a_min
# a_min and a_max might be ndarray subclasses so use
# asscalar to ensure they are scalars to avoid errors
# asscalar to avoid errors
a_min = np.asscalar(a_min.astype(scaled_dtype))
a_max = np.asscalar(a_max.astype(scaled_dtype))

Expand Down
0