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
#13171 documented how to construct a colorbar "without an associated artist", via fig.colorbar(cm.ScalarMappable(norm=norm, cmap=cmap), ax=ax). It is also possible e.g. to update the colorbar via
sm = ScalarMappable(norm=norm, cmap=cmap)
fig.colorbar(sm)
<...>
sm.set_cmap("plasma")
(Although this is only documented in master, the recipe has existed for a while.)
Traceback (most recent call last):
File "lib/matplotlib/cbook/__init__.py", line 214, in process
func(*args, **kwargs)
File "lib/matplotlib/colorbar.py", line 1189, in on_mappable_changed
self.update_normal(mappable)
File "lib/matplotlib/colorbar.py", line 1230, in update_normal
self.set_alpha(mappable.get_alpha())
AttributeError: 'ScalarMappable' object has no attribute 'get_alpha'
Indeed, the ScalarMappable class does not define get_alpha(). I think the solutions are either to make Colorbar.update_normal first check for whether such a method exists, or to add a dummy get_alpha() (always returning 1) to ScalarMappable.
Allowing myself to label as release critical (as a regression) but feel free to relabel if you disagree.
Activity