You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug summary
Creating a colorbar with a SymLogNorm fails, using the fig.colorbar(cm.ScalarMappable(norm=norm, cmap=cmap), ax=ax) example given in the docs.
diff --git i/lib/matplotlib/colors.py w/lib/matplotlib/colors.py
index 2f8c89265..598956d76 100644
--- i/lib/matplotlib/colors.py+++ w/lib/matplotlib/colors.py@@ -1213,8 +1213,14 @@ class SymLogNorm(Normalize):
Normalize.__init__(self, vmin, vmax, clip)
self.linthresh = float(linthresh)
self._linscale_adj = (linscale / (1.0 - np.e ** -1))
- if vmin is not None and vmax is not None:- self._transform_vmin_vmax()++ @property+ def _lower(self):+ return self._transform(np.array(self.vmin, float))++ @property+ def _upper(self):+ return self._transform(np.array(self.vmax, float))
def __call__(self, value, clip=None):
if clip is None:
@@ -1263,12 +1269,6 @@ class SymLogNorm(Normalize):
a[~masked] /= self._linscale_adj
return a
- def _transform_vmin_vmax(self):- """Calculates vmin and vmax in the transformed system."""- vmin, vmax = self.vmin, self.vmax- arr = np.array([vmax, vmin]).astype(float)- self._upper, self._lower = self._transform(arr)-
def inverse(self, value):
if not self.scaled():
raise ValueError("Not invertible until scaled")
@@ -1276,16 +1276,6 @@ class SymLogNorm(Normalize):
val = val * (self._upper - self._lower) + self._lower
return self._inv_transform(val)
- def autoscale(self, A):- # docstring inherited.- super().autoscale(A)- self._transform_vmin_vmax()-- def autoscale_None(self, A):- # docstring inherited.- super().autoscale_None(A)- self._transform_vmin_vmax()-
class PowerNorm(Normalize):
"""
appears to fix it (and is also likely more correct against the case where the user directly assigns to .vmin/.vmax). I guess we could cache _upper and _lower and detect when vmin/vmax change (e.g. using lru_cache or whatnot)... but I doubt that the recomputation is a bottleneck (you're going to compute the transform over a large number of actual values other than vmin/vmax, anyways).
Bug report
Bug summary
Creating a colorbar with a
SymLogNorm
fails, using thefig.colorbar(cm.ScalarMappable(norm=norm, cmap=cmap), ax=ax)
example given in the docs.Code for reproduction
Actual outcome
Expected outcome
No error
Matplotlib version
print(matplotlib.get_backend())
): Qt5AggThe text was updated successfully, but these errors were encountered: