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 38ad08e

Browse filesBrowse files
committed
FIX: use left and right
1 parent 9ef1caa commit 38ad08e
Copy full SHA for 38ad08e

File tree

Expand file treeCollapse file tree

2 files changed

+12
-18
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-18
lines changed

‎lib/matplotlib/colors.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colors.py
+6-9Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,13 +1300,11 @@ def __call__(self, value, clip=None):
13001300

13011301
if not self.vmin <= self.vcenter <= self.vmax:
13021302
raise ValueError("vmin, vcenter, vmax must increase monotonically")
1303-
# must linearly extrapolate for ticks on colorbars that go
1304-
# beyond vmin and vmax:
1305-
min = self.vmin - (self.vcenter - self.vmin)
1306-
max = self.vmax + (self.vmax - self.vcenter)
1303+
# note that we must extrapolate for tick locators:
13071304
result = np.ma.masked_array(
1308-
np.interp(result, [min, self.vcenter, max],
1309-
[-0.5, 0.5, 1.5]), mask=np.ma.getmask(result))
1305+
np.interp(result, [self.vmin, self.vcenter, self.vmax],
1306+
[0, 0.5, 1], left=-np.inf, right=np.inf),
1307+
mask=np.ma.getmask(result))
13101308
if is_scalar:
13111309
result = np.atleast_1d(result)[0]
13121310
return result
@@ -1317,9 +1315,8 @@ def inverse(self, value):
13171315
(vmin,), _ = self.process_value(self.vmin)
13181316
(vmax,), _ = self.process_value(self.vmax)
13191317
(vcenter,), _ = self.process_value(self.vcenter)
1320-
min = vmin - (vcenter - vmin)
1321-
max = vmax + (vmax - vcenter)
1322-
result = np.interp(value, [-0.5, 0.5, 1.5], [min, vcenter, max])
1318+
result = np.interp(value, [0, 0.5, 1], [vmin, vcenter, vmax],
1319+
left=-np.inf, right=np.inf)
13231320
return result
13241321

13251322

‎tutorials/colors/colormapnorms.py

Copy file name to clipboardExpand all lines: tutorials/colors/colormapnorms.py
+6-9Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -325,17 +325,14 @@ def __init__(self, vmin=None, vmax=None, vcenter=None, clip=False):
325325
def __call__(self, value, clip=None):
326326
# I'm ignoring masked values and all kinds of edge cases to make a
327327
# simple example...
328-
# Note also that we must extrapolate linearly beyond vmin/vmax
329-
min = self.vmin - (self.vcenter - self.vmin)
330-
max = self.vmax + (self.vmax - self.vcenter)
331-
x, y = [min, self.vcenter, max], [-0.5, 0.5, 1.5]
332-
return np.ma.masked_array(np.interp(value, x, y))
328+
# Note also that we must extrapolate beyond vmin/vmax
329+
x, y = [self.vmin, self.vcenter, self.vmax], [0, 0.5, 1.]
330+
return np.ma.masked_array(np.interp(value, x, y,
331+
left=-np.inf, right=np.inf))
333332

334333
def inverse(self, value):
335-
min = self.vmin - (self.vcenter - self.vmin)
336-
max = self.vmax + (self.vmax - self.vcenter)
337-
y, x = [min, self.vcenter, max], [-0.5, 0.5, 1.5]
338-
return np.interp(value, x, y)
334+
y, x = [self.vmin, self.vcenter, self.vmax], [0, 0.5, 1]
335+
return np.interp(value, x, y, left=-np.inf, right=np.inf)
339336

340337

341338
fig, ax = plt.subplots()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.