Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Milestone
Description
As noted in#18653, norms created viacolors._make_norm_from_scale
do not process values that are passed toinverse
sonorm.inverse([0.2, 5, 10])
fails, whereasnorm.inverse(np.array([0.2, 5, 10]))
works fine.
@QuLogic noticed this:
Probably becauseinverse
doesn't passvalue
throughprocess_value
like__call__
does. Something like:
diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.pyindex e417b8178d..b37ec947fa 100644--- a/lib/matplotlib/colors.py+++ b/lib/matplotlib/colors.py@@ -1449,12 +1449,14 @@ def _make_norm_from_scale(scale_cls, base_norm_cls=None, *, init=None): t_vmin, t_vmax = self._trf.transform([self.vmin, self.vmax]) if not np.isfinite([t_vmin, t_vmax]).all(): raise ValueError("Invalid vmin or vmax")+ value, is_scalar = self.process_value(value) rescaled = value * (t_vmax - t_vmin) rescaled += t_vmin- return (self._trf- .inverted()- .transform(rescaled)- .reshape(np.shape(value)))+ t_value = (self._trf+ .inverted()+ .transform(rescaled)+ .reshape(np.shape(value)))+ return t_value[0] if is_scalar else t_value Norm.__name__ = base_norm_cls.__name__ Norm.__qualname__ = base_norm_cls.__qualname__
Maybe it also needs the masking?
Originally posted by@QuLogic in#18653 (comment)