Skip to content

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

Closed

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

Activity

  1. efiring commented on Sep 27, 2017

    @efiring
    Member

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

  2. self-assigned this
    on Sep 27, 2017
  3. jklymak commented on Sep 27, 2017

    @jklymak
    MemberAuthor

    ... for a less-pathalogical example:

    fig, ax = plt.subplots(figsize=(4, 2))
    pc = ax.pcolormesh(X)
    fig.colorbar(pc, shrink=0.4)
    plt.show()
  4. added this to the milestone on Nov 25, 2017
  5. modified the milestones: , on Mar 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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