Skip to content

Commit de40172

Browse files
committed
Simplify symlog range determination logic
1 parent 6ec75f5 commit de40172

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
@@ -2408,30 +2408,17 @@ def tick_values(self, vmin, vmax):
24082408
#
24092409
# "simple" mode is when the range falls entirely within (-t,
24102410
# t) -- it should just display (vmin, 0, vmax)
2411+
if -linthresh < vmin < vmax < linthresh:
2412+
# only the linear range is present
2413+
return [vmin, vmax]
24112414

2412-
# Determine which of the three ranges we have
2413-
has_a = has_b = has_c = False
2414-
if vmin < -linthresh:
2415-
has_a = True
2416-
if vmax > -linthresh:
2417-
has_b = True
2418-
if vmax > linthresh:
2419-
has_c = True
2420-
elif vmin < 0:
2421-
if vmax > 0:
2422-
has_b = True
2423-
if vmax > linthresh:
2424-
has_c = True
2425-
else:
2426-
return [vmin, vmax]
2427-
elif vmin < linthresh:
2428-
if vmax > linthresh:
2429-
has_b = True
2430-
has_c = True
2431-
else:
2432-
return [vmin, vmax]
2433-
else:
2434-
has_c = True
2415+
# Lower log range is present
2416+
has_a = (vmin < -linthresh)
2417+
# Upper log range is present
2418+
has_c = (vmax > linthresh)
2419+
2420+
# Check if linear range is present
2421+
has_b = (has_a and vmax > -linthresh) or (has_c and vmin < linthresh)
24352422

24362423
def get_log_range(lo, hi):
24372424
lo = np.floor(np.log(lo) / np.log(base))

0 commit comments

Comments
 (0)