Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fdc7a8c

Browse filesBrowse files
authored
Merge pull request #14308 from dstansby/symlog-clean
Small clean to SymmetricalLogLocator
2 parents 012d055 + c39f4a6 commit fdc7a8c
Copy full SHA for fdc7a8c

File tree

Expand file treeCollapse file tree

1 file changed

+20
-18
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+20
-18
lines changed

‎lib/matplotlib/ticker.py

Copy file name to clipboardExpand all lines: lib/matplotlib/ticker.py
+20-18Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,8 +2383,8 @@ def __call__(self):
23832383
return self.tick_values(vmin, vmax)
23842384

23852385
def tick_values(self, vmin, vmax):
2386-
b = self._base
2387-
t = self._linthresh
2386+
base = self._base
2387+
linthresh = self._linthresh
23882388

23892389
if vmax < vmin:
23902390
vmin, vmax = vmax, vmin
@@ -2409,22 +2409,23 @@ def tick_values(self, vmin, vmax):
24092409
# "simple" mode is when the range falls entirely within (-t,
24102410
# t) -- it should just display (vmin, 0, vmax)
24112411

2412+
# Determine which of the three ranges we have
24122413
has_a = has_b = has_c = False
2413-
if vmin < -t:
2414+
if vmin < -linthresh:
24142415
has_a = True
2415-
if vmax > -t:
2416+
if vmax > -linthresh:
24162417
has_b = True
2417-
if vmax > t:
2418+
if vmax > linthresh:
24182419
has_c = True
24192420
elif vmin < 0:
24202421
if vmax > 0:
24212422
has_b = True
2422-
if vmax > t:
2423+
if vmax > linthresh:
24232424
has_c = True
24242425
else:
24252426
return [vmin, vmax]
2426-
elif vmin < t:
2427-
if vmax > t:
2427+
elif vmin < linthresh:
2428+
if vmax > linthresh:
24282429
has_b = True
24292430
has_c = True
24302431
else:
@@ -2433,46 +2434,47 @@ def tick_values(self, vmin, vmax):
24332434
has_c = True
24342435

24352436
def get_log_range(lo, hi):
2436-
lo = np.floor(np.log(lo) / np.log(b))
2437-
hi = np.ceil(np.log(hi) / np.log(b))
2437+
lo = np.floor(np.log(lo) / np.log(base))
2438+
hi = np.ceil(np.log(hi) / np.log(base))
24382439
return lo, hi
24392440

2440-
# First, calculate all the ranges, so we can determine striding
2441+
# Calculate all the ranges, so we can determine striding
24412442
if has_a:
24422443
if has_b:
2443-
a_range = get_log_range(t, -vmin + 1)
2444+
a_range = get_log_range(linthresh, np.abs(vmin) + 1)
24442445
else:
2445-
a_range = get_log_range(-vmax, -vmin + 1)
2446+
a_range = get_log_range(np.abs(vmax), np.abs(vmin) + 1)
24462447
else:
24472448
a_range = (0, 0)
24482449

24492450
if has_c:
24502451
if has_b:
2451-
c_range = get_log_range(t, vmax + 1)
2452+
c_range = get_log_range(linthresh, vmax + 1)
24522453
else:
24532454
c_range = get_log_range(vmin, vmax + 1)
24542455
else:
24552456
c_range = (0, 0)
24562457

2458+
# Calculate the total number of integer exponents in a and c ranges
24572459
total_ticks = (a_range[1] - a_range[0]) + (c_range[1] - c_range[0])
24582460
if has_b:
24592461
total_ticks += 1
24602462
stride = max(total_ticks // (self.numticks - 1), 1)
24612463

24622464
decades = []
24632465
if has_a:
2464-
decades.extend(-1 * (b ** (np.arange(a_range[0], a_range[1],
2465-
stride)[::-1])))
2466+
decades.extend(-1 * (base ** (np.arange(a_range[0], a_range[1],
2467+
stride)[::-1])))
24662468

24672469
if has_b:
24682470
decades.append(0.0)
24692471

24702472
if has_c:
2471-
decades.extend(b ** (np.arange(c_range[0], c_range[1], stride)))
2473+
decades.extend(base ** (np.arange(c_range[0], c_range[1], stride)))
24722474

24732475
# Add the subticks if requested
24742476
if self._subs is None:
2475-
subs = np.arange(2.0, b)
2477+
subs = np.arange(2.0, base)
24762478
else:
24772479
subs = np.asarray(self._subs)
24782480

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.