8000 ENH: make default colorbar ticks adjust as nicely as axes ticks · Issue #9246 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
ENH: make default colorbar ticks adjust as nicely as axes ticks #9246
Closed
@jklymak

Description

@jklymak

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0