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

using AxesImage.set_clim() shrinks the colorbar · Issue #12682 · matplotlib/matplotlib · GitHub

Repository navigation

using AxesImage.set_clim() shrinks the colorbar #12682

Closed

Description

Bug report

Bug summary
I am puzzled by the following behavior. Is this intended or a bug?

After creating a colorbar, if setting the limits of the color range with a shorter range of vmin,vmax results in a shrunken colorbar

Code for reproduction

fig, ax = plt.subplots()
data = np.random.random(size=(50,50))
img = ax.imshow(data)
cb = plt.colorbar(img)
# the colorbar is the same height as the plot at this point
#img.set_clim([0.25,0.75])  # running this line will produce a shrunken colorbar
#img.set_clim([-0.25,1.25])  # running this line will change the limits of the colorbar
                             # and return the colorbar to its original size

Actual outcome

This is the result of a small animation where vmax is increased from 0.5 to 1.5 then back

Expected outcome

I was expecting the colorbar to stay the same size, and only the tick range to change. Certainly the colorbar does not grow when setting a larger range of vmin,vmax but shrinks when using a smaller range, which seems inconsistent.

Matplotlib version

  • Operating system: osx
  • Matplotlib version: 3.0.0
  • Matplotlib backend (print(matplotlib.get_backend())): nbAgg
  • Python version: Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:07:29)
  • Jupyter version (if applicable):The version of the notebook server is: 5.7.0
  • Other libraries:

Activity

  1. ImportanceOfBeingErnest commented on Oct 31, 2018

    Member

    Thanks for reporting this. This is a bug introduced in #9903
    and fixed by #12159. It will not occur any more in matplotlib 3.0.1 which is available since 6 days ago.

    I will close this. If you find some undesired behaviour concerning colorbar limits in version 3.0.1 feel free to reopen.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL