diff --git a/lib/matplotlib/tests/test_ticker.py b/lib/matplotlib/tests/test_ticker.py index b0ecb72dfdb4..02c2ecfaeff0 100644 --- a/lib/matplotlib/tests/test_ticker.py +++ b/lib/matplotlib/tests/test_ticker.py @@ -183,6 +183,10 @@ def test_switch_to_autolocator(self): loc = mticker.LogLocator(subs="all") assert_array_equal(loc.tick_values(0.45, 0.55), [0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56]) + # check that we *skip* 1.0, and 10, because this is a minor locator + loc = mticker.LogLocator(subs=np.arange(2, 10)) + assert 1.0 not in loc.tick_values(0.9, 20.) + assert 10.0 not in loc.tick_values(0.9, 20.) def test_set_params(self): """ diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index 89e077a04262..c68ef258dcd9 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -2093,9 +2093,7 @@ def is_decade(x, base=10): def is_close_to_int(x): - if not np.isfinite(x): - return False - return abs(x - round(x)) < 1e-10 + return abs(x - np.round(x)) < 1e-10 class LogLocator(Locator): @@ -2256,7 +2254,12 @@ def tick_values(self, vmin, vmax): # If we're a minor locator *that expects at least two ticks per # decade* and the major locator stride is 1 and there's no more # than one minor tick, switch to AutoLocator. - return AutoLocator().tick_values(vmin, vmax) + ticklocs = AutoLocator().tick_values(vmin, vmax) + # Don't overstrike the major labels. Assumes major locs are + # at b = self._base + ticklocs = ticklocs[ + ~is_close_to_int(np.log(ticklocs) / np.log(b))] + return ticklocs return self.raise_if_exceeds(ticklocs) def view_limits(self, vmin, vmax): 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