Skip to content

Commit 0307ade

Browse files
committed
Simplify symlog range determination logic
1 parent 81b5944 commit 0307ade

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

lib/matplotlib/ticker.py

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2581,30 +2581,17 @@ def tick_values(self, vmin, vmax):
25812581
#
25822582
# "simple" mode is when the range falls entirely within (-t,
25832583
# t) -- it should just display (vmin, 0, vmax)
2584+
if -linthresh < vmin < vmax < linthresh:
2585+
# only the linear range is present
2586+
return [vmin, vmax]
25842587

2585-
# Determine which of the three ranges we have
2586-
has_a = has_b = has_c = False
2587-
if vmin < -linthresh:
2588-
has_a = True
2589-
if vmax > -linthresh:
2590-
has_b = True
2591-
if vmax > linthresh:
2592-
has_c = True
2593-
elif vmin < 0:
2594-
if vmax > 0:
2595-
has_b = True
2596-
if vmax > linthresh:
2597-
has_c = True
2598-
else:
2599-
return [vmin, vmax]
2600-
elif vmin < linthresh:
2601-
if vmax > linthresh:
2602-
has_b = True
2603-
has_c = True
2604-
else:
2605-
return [vmin, vmax]
2606-
else:
2607-
has_c = True
2588+
# Lower log range is present
2589+
has_a = (vmin < -linthresh)
2590+
# Upper log range is present
2591+
has_c = (vmax > linthresh)
2592+
2593+
# Check if linear range is present
2594+
has_b = (has_a and vmax > -linthresh) or (has_c and vmin < linthresh)
26082595

26092596
def get_log_range(lo, hi):
26102597
lo = np.floor(np.log(lo) / np.log(base))

0 commit comments

Comments
 (0)