Skip to content

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

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
pharshalp opened this issue Feb 11, 2020 · 0 comments · Fixed by #16469
Closed

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

pharshalp opened this issue Feb 11, 2020 · 0 comments · Fixed by #16469

Comments

@pharshalp
Copy link
Contributor

pharshalp commented Feb 11, 2020

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants