Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/matplotlib/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,12 @@ def _config_axis(self):

if self.orientation == 'vertical':
long_axis, short_axis = ax.yaxis, ax.xaxis
if mpl.rcParams['ytick.minor.visible']:
self.minorticks_on()
else:
long_axis, short_axis = ax.xaxis, ax.yaxis
if mpl.rcParams['xtick.minor.visible']:
self.minorticks_on()

long_axis.set_label_position(self.ticklocation)
long_axis.set_ticks_position(self.ticklocation)
Expand Down
28 changes: 28 additions & 0 deletions lib/matplotlib/tests/test_colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,34 @@ def test_colorbar_minorticks_on_off():
np.testing.assert_equal(cbar.ax.yaxis.get_minorticklocs(), [])


def test_cbar_minorticks_for_rc_xyminortickvisible():
"""
issue gh-16468.

Making sure that minor ticks on the colorbar are turned on
(internally) using the cbar.minorticks_on() method when
rcParams['xtick.minor.visible'] = True (for horizontal cbar)
rcParams['ytick.minor.visible'] = True (for vertical cbar).
Using cbar.minorticks_on() ensures that the minor ticks
don't overflow into the extend regions of the colorbar.
"""

plt.rcParams['ytick.minor.visible'] = True
plt.rcParams['xtick.minor.visible'] = True

vmin, vmax = 0.4, 2.6
fig, ax = plt.subplots()
im = ax.pcolormesh([[1, 2]], vmin=vmin, vmax=vmax)

cbar = fig.colorbar(im, extend='both', orientation='vertical')
assert cbar.ax.yaxis.get_minorticklocs()[0] >= vmin
assert cbar.ax.yaxis.get_minorticklocs()[-1] <= vmax

cbar = fig.colorbar(im, extend='both', orientation='horizontal')
assert cbar.ax.xaxis.get_minorticklocs()[0] >= vmin
assert cbar.ax.xaxis.get_minorticklocs()[-1] <= vmax


def test_colorbar_autoticks():
# Test new autotick modes. Needs to be classic because
# non-classic doesn't go this route.
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy