Skip to content

Commit 28c659b

Browse files
committed
ENH: allow extrapolation
1 parent 3179797 commit 28c659b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/matplotlib/colors.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -1044,9 +1044,14 @@ def __call__(self, value, clip=None):
10441044
raise ValueError("data points must increase monotonically")
10451045
ind = np.where((self._data_points >= vmin) &
10461046
(self._data_points <= vmax))[0]
1047+
if clip == None:
1048+
left, right = -1, 2
1049+
else:
1050+
left, right = 0, 1
10471051
result = np.ma.masked_array(np.interp(result,
10481052
self._data_points[ind],
1049-
self._norm_points[ind]),
1053+
self._norm_points[ind],
1054+
left=left, right=right),
10501055
mask=np.ma.getmask(result))
10511056
if is_scalar:
10521057
result = np.atleast_1d(result)[0]
@@ -1139,12 +1144,11 @@ def __init__(self, vmin=None, vcenter=None, vmax=None):
11391144
# will autoscale to data.
11401145
self.vmin = vmin
11411146
self.vmax = vmax
1142-
if vcenter is not None and vmax is not None and vcenter > vmax:
1143-
raise ValueError('vmin, vcenter, and vmax must be in '
1144-
'ascending order')
1145-
if vcenter is not None and vmin is not None and vcenter < vmin:
1146-
raise ValueError('vmin, vcenter, and vmax must be in '
1147-
'ascending order')
1147+
if vcenter is not None:
1148+
if ((vmax is not None and vcenter > vmax) or
1149+
(vmin is not None and vcenter < vmin)):
1150+
raise ValueError('DivergingNorm requires that '
1151+
'vmin < vcenter < vmax')
11481152

11491153
def __call__(value, clip=None):
11501154
"""

0 commit comments

Comments
 (0)