Skip to content

ENH: make default colorbar ticks adjust as nicely as axes ticks #9246

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
jklymak opened this issue Sep 27, 2017 · 2 comments
Closed

ENH: make default colorbar ticks adjust as nicely as axes ticks #9246

jklymak opened this issue Sep 27, 2017 · 2 comments
Assignees
Milestone

Comments

@jklymak
Copy link
Member

jklymak commented Sep 27, 2017

Bug report

Bug summary

It would be nice if the colorbars changed their number of ticks if the colorbar gets small.

Code for reproduction

import matplotlib
import matplotlib.pyplot as plt
import numpy as np

X = np.random.rand(32,32)*20.

fig, ax = plt.subplots()
pc = ax.pcolormesh(X)
fig.colorbar(pc)

plt.show()

fig, ax = plt.subplots(figsize=(4, 1.))
pc = ax.pcolormesh(X)
fig.colorbar(pc)

plt.show()

Actual outcome

Expected outcome

The full sized plot has 7 y-ticks and 7 colorbar ticks. Whichs is fine.

figure_1

If I make the plot much smaller (as can happen if I have a bunch of subplots), then the y-axis decreases its number of ticks, but the colorbar doesn't.

figure_1

No idea how easy this is, and I don't think its a must-do (we can use a manual locator), but it does seem the default should be that the colorbar gets treated as well as the y-axis.

Matplotlib version

  • Master
@efiring
Copy link
Member

efiring commented Sep 27, 2017

Agreed. I have had some colorbar tick handling changes in mind for a while but haven't gotten to them.

@efiring efiring self-assigned this Sep 27, 2017
@jklymak
Copy link
Member Author

jklymak commented Sep 27, 2017

... for a less-pathalogical example:

fig, ax = plt.subplots(figsize=(4, 2))
pc = ax.pcolormesh(X)
fig.colorbar(pc, shrink=0.4)
plt.show()

@jklymak jklymak added this to the v2.2 milestone Nov 25, 2017
@jklymak jklymak modified the milestones: needs sorting, v3.0 Mar 28, 2018
@jklymak jklymak closed this as completed Mar 28, 2018
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