Skip to content

using AxesImage.set_clim() shrinks the colorbar #12682

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
DizietAsahi opened this issue Oct 31, 2018 · 1 comment
Closed

using AxesImage.set_clim() shrinks the colorbar #12682

DizietAsahi opened this issue Oct 31, 2018 · 1 comment

Comments

@DizietAsahi
Copy link

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

test

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:
@ImportanceOfBeingErnest
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants