Skip to content

Dataless colorbars break when updated #13963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
anntzer opened this issue Apr 15, 2019 · 0 comments · Fixed by #13966
Closed

Dataless colorbars break when updated #13963

anntzer opened this issue Apr 15, 2019 · 0 comments · Fixed by #13966
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: color/colorbar
Milestone

Comments

@anntzer
Copy link
Contributor

anntzer commented Apr 15, 2019

#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.)

But this got broken by #13234: one now gets

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.


mpl master, arch linux, py3.7

@anntzer anntzer added Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: color/colorbar labels Apr 15, 2019
@anntzer anntzer added this to the v3.1.0 milestone Apr 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: color/colorbar
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant