diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index d88fcedb65d4..0a2bfe1140ee 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -267,7 +267,8 @@ def __call__(self): vmin = self._colorbar.norm.vmin vmax = self._colorbar.norm.vmax ticks = ticker.AutoMinorLocator.__call__(self) - return ticks[(ticks >= vmin) & (ticks <= vmax)] + rtol = (vmax - vmin) * 1e-10 + return ticks[(ticks >= vmin - rtol) & (ticks <= vmax + rtol)] class _ColorbarLogLocator(ticker.LogLocator): diff --git a/lib/matplotlib/tests/test_colorbar.py b/lib/matplotlib/tests/test_colorbar.py index 2230c20e7d2f..56a829418910 100644 --- a/lib/matplotlib/tests/test_colorbar.py +++ b/lib/matplotlib/tests/test_colorbar.py @@ -294,6 +294,15 @@ def test_colorbar_minorticks_on_off(): np.testing.assert_almost_equal(cbar.ax.yaxis.get_minorticklocs(), np.array([])) + im.set_clim(vmin=-1.2, vmax=1.2) + cbar.minorticks_on() + correct_minorticklocs = np.array([-1.2, -1.1, -0.9, -0.8, -0.7, -0.6, + -0.4, -0.3, -0.2, -0.1, 0.1, 0.2, + 0.3, 0.4, 0.6, 0.7, 0.8, 0.9, + 1.1, 1.2]) + np.testing.assert_almost_equal(cbar.ax.yaxis.get_minorticklocs(), + correct_minorticklocs) + def test_colorbar_autoticks(): # Test new autotick modes. Needs to be classic because 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