Skip to content

Commit 2c3f3d4

Browse files
committed
Simplify a and c range determination
1 parent 0307ade commit 2c3f3d4

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

lib/matplotlib/ticker.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,24 +2599,18 @@ def get_log_range(lo, hi):
25992599
return lo, hi
26002600

26012601
# Calculate all the ranges, so we can determine striding
2602+
a_lo, a_hi = (0, 0)
26022603
if has_a:
2603-
if has_b:
2604-
a_range = get_log_range(linthresh, np.abs(vmin) + 1)
2605-
else:
2606-
a_range = get_log_range(np.abs(vmax), np.abs(vmin) + 1)
2607-
else:
2608-
a_range = (0, 0)
2604+
a_upper_lim = min(-linthresh, vmax)
2605+
a_lo, a_hi = get_log_range(np.abs(a_upper_lim), np.abs(vmin) + 1)
26092606

2607+
c_lo, c_hi = (0, 0)
26102608
if has_c:
2611-
if has_b:
2612-
c_range = get_log_range(linthresh, vmax + 1)
2613-
else:
2614-
c_range = get_log_range(vmin, vmax + 1)
2615-
else:
2616-
c_range = (0, 0)
2609+
c_lower_lim = max(linthresh, vmin)
2610+
c_lo, c_hi = get_log_range(c_lower_lim, vmax + 1)
26172611

26182612
# Calculate the total number of integer exponents in a and c ranges
2619-
total_ticks = (a_range[1] - a_range[0]) + (c_range[1] - c_range[0])
2613+
total_ticks = (a_hi - a_lo) + (c_hi - c_lo)
26202614
if has_b:
26212615
total_ticks += 1
26222616
stride = max(total_ticks // (self.numticks - 1), 1)

0 commit comments

Comments
 (0)