8000 early return in AutoMinorLocator if < 2 major ticks · matplotlib/matplotlib@1abd72d · GitHub
[go: up one dir, main page]

Skip to content

Commit 1abd72d

Browse files
committed
early return in AutoMinorLocator if < 2 major ticks
1 parent 075618b commit 1abd72d

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

lib/matplotlib/ticker.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2524,18 +2524,14 @@ def __call__(self):
25242524
# TODO: Figure out a way to still be able to display minor
25252525
# ticks without two major ticks visible. For now, just display
25262526
# no ticks at all.
2527-
majorstep = 0
2527+
return []
25282528

25292529
if self.ndivs is None:
2530-
if majorstep == 0:
2531-
# TODO: Need a better way to figure out ndivs
2532-
ndivs = 1
2530+
x = int(np.round(10 ** (np.log10(majorstep) % 1)))
2531+
if x in [1, 5, 10]:
2532+
ndivs = 5
25332533
else:
2534-
x = int(np.round(10 ** (np.log10(majorstep) % 1)))
2535-
if x in [1, 5, 10]:
2536-
ndivs = 5
2537-
else:
2538-
ndivs = 4
2534+
ndivs = 4
25392535
else:
25402536
ndivs = self.ndivs
25412537

@@ -2545,15 +2541,12 @@ def __call__(self):
25452541
if vmin > vmax:
25462542
vmin, vmax = vmax, vmin
25472543

2548-
if len(majorlocs) > 0:
2549-
t0 = majorlocs[0]
2550-
tmin = ((vmin - t0) // minorstep + 1) * minorstep
2551-
tmax = ((vmax - t0) // minorstep + 1) * minorstep
2552-
locs = np.arange(tmin, tmax, minorstep) + t0
2553-
cond = np.abs((locs - t0) % majorstep) > minorstep / 10.0
2554-
locs = locs.compress(cond)
2555-
else:
2556-
locs = []
2544+
t0 = majorlocs[0]
2545+
tmin = ((vmin - t0) // minorstep + 1) * minorstep
2546+
tmax = ((vmax - t0) // minorstep + 1) * minorstep
2547+
locs = np.arange(tmin, tmax, minorstep) + t0
2548+
cond = np.abs((locs - t0) % majorstep) > minorstep / 10.0
2549+
locs = locs.compress(cond)
25572550

25582551
return self.raise_if_exceeds(np.array(locs))
25592552

0 commit comments

Comments
 (0)
0