10000 FIX: log axes: don't choose major ticks as a minor tick · matplotlib/matplotlib@339d762 · GitHub
[go: up one dir, main page]

Skip to content

Commit 339d762

Browse files
committed
FIX: log axes: don't choose major ticks as a minor tick
1 parent af8a720 commit 339d762

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/matplotlib/ticker.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,9 +2093,7 @@ def is_decade(x, base=10):
20932093

20942094

20952095
def is_close_to_int(x):
2096-
if not np.isfinite(x):
2097-
return False
2098-
return abs(x - round(x)) < 1e-10
2096+
return abs(x - np.round(x)) < 1e-10
20992097

21002098

21012099
class LogLocator(Locator):
@@ -2256,7 +2254,11 @@ def tick_values(self, vmin, vmax):
22562254
# If we're a minor locator *that expects at least two ticks per
22572255
# decade* and the major locator stride is 1 and there's no more
22582256
# than one minor tick, switch to AutoLocator.
2259-
return AutoLocator().tick_values(vmin, vmax)
2257+
ticklocs = AutoLocator().tick_values(vmin, vmax)
2258+
# Don't overstrike the major labels.
2259+
ticklocs = ticklocs[
2260+
~is_close_to_int(np.log(ticklocs) / np.log(b))]
2261+
return ticklocs
22602262
return self.raise_if_exceeds(ticklocs)
22612263

22622264
def view_limits(self, vmin, vmax):

0 commit comments

Comments
 (0)
0