8000 Merge pull request #12866 from anntzer/logstride · matplotlib/matplotlib@d4b42b6 · GitHub
[go: up one dir, main page]

Skip to content

Commit d4b42b6

Browse files
authored
Merge pull request #12866 from anntzer/logstride
Simplify stride calculations in loglocator.
2 parents 71d0070 + a06f343 commit d4b42b6

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

lib/matplotlib/ticker.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,15 +2185,10 @@ def tick_values(self, vmin, vmax):
21852185
else:
21862186
subs = self._subs
21872187

2188-
# get decades between major ticks.
2189-
stride = 1
2190-
if rcParams['_internal.classic_mode']:
2191-
# Leave the bug left over from the PY2-PY3 transition.
2192-
while numdec / stride + 1 > numticks:
2193-
stride += 1
2194-
else:
2195-
while numdec // stride + 1 > numticks:
2196-
stride += 1
2188+
# Get decades between major ticks.
2189+
stride = (max(math.ceil(numdec / (numticks - 1)), 1)
2190+
if rcParams['_internal.classic_mode'] else
2191+
(numdec + 1) // numticks + 1)
21972192

21982193
# Does subs include anything other than 1?
21992194
have_subs = len(subs) > 1 or (len(subs) == 1 and subs[0] != 1.0)

0 commit comments

Comments
 (0)
0