@@ -1300,13 +1300,11 @@ def __call__(self, value, clip=None):
1300
1300
1301
1301
if not self .vmin <= self .vcenter <= self .vmax :
1302
1302
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:
1307
1304
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 ))
1310
1308
if is_scalar :
1311
1309
result = np .atleast_1d (result )[0 ]
1312
1310
return result
@@ -1317,9 +1315,8 @@ def inverse(self, value):
1317
1315
(vmin ,), _ = self .process_value (self .vmin )
1318
1316
(vmax ,), _ = self .process_value (self .vmax )
1319
1317
(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 )
1323
1320
return result
1324
1321
1325
1322
0 commit comments