Skip to content

incorrect cbar minor ticks for extend regions when x/ytick.minor.visible is True #16468

Closed

Description

@pharshalp

Bug report

Bug summary
Colorbars have their own minorticks_on/off methods to address the issue of minorticks extending into the "extend" regions (see #11584).

Since colorbar axes are instances of normal axes, setting rcParams['y/xtick.minor.visible'] = True
results in minorticks being drawn on the colorbar axes using the axes methods (which don't take into account the "extend" regions).

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

# Making yticks longer in length to highlight the issue
plt.rcParams['ytick.major.size'] = 10
plt.rcParams['ytick.minor.size'] = 4
plt.rcParams['ytick.minor.visible'] = True
# Similar issue with plt.rcParams['xtick.minor.visible'] = True and horizontal colorbar

np.random.seed(seed=12345)
x = np.random.randn(20, 20)
fig, ax = plt.subplots(figsize=(4, 3), constrained_layout=True)
im = ax.pcolormesh(x)

cbar = fig.colorbar(im, extend='both', orientation='vertical')
# Similar issue with plt.rcParams['xtick.minor.visible'] = True and horizontal colorbar
fig.savefig('cbar_minorticks_issue.png')

Actual outcome
cbar_minorticks_issue

Expected outcome
cbar_minorticks_fixed

Matplotlib version

  • Operating system:
  • Matplotlib version:
  • Matplotlib backend (print(matplotlib.get_backend())):
  • Python version:
  • Jupyter version (if applicable):
  • Other libraries:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions