FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Dataless colorbars break when updated · Issue #13963 · matplotlib/matplotlib · GitHub

Repository navigation

Dataless colorbars break when updated #13963

Closed

Description

#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

Activity

  1. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Apr 15, 2019
  2. added this to the v3.1.0 milestone on Apr 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.topic: color/colorbar

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL