@@ -2383,8 +2383,8 @@ def __call__(self):
2383
2383
return self .tick_values (vmin , vmax )
2384
2384
2385
2385
def tick_values (self , vmin , vmax ):
2386
- b = self ._base
2387
- t = self ._linthresh
2386
+ base = self ._base
2387
+ linthresh = self ._linthresh
2388
2388
2389
2389
if vmax < vmin :
2390
2390
vmin , vmax = vmax , vmin
@@ -2409,22 +2409,23 @@ def tick_values(self, vmin, vmax):
2409
2409
# "simple" mode is when the range falls entirely within (-t,
2410
2410
# t) -- it should just display (vmin, 0, vmax)
2411
2411
2412
+ # Determine which of the three ranges we have
2412
2413
has_a = has_b = has_c = False
2413
- if vmin < - t :
2414
+ if vmin < - linthresh :
2414
2415
has_a = True
2415
- if vmax > - t :
2416
+ if vmax > - linthresh :
2416
2417
has_b = True
2417
- if vmax > t :
2418
+ if vmax > linthresh :
2418
2419
has_c = True
2419
2420
elif vmin < 0 :
2420
2421
if vmax > 0 :
2421
2422
has_b = True
2422
- if vmax > t :
2423
+ if vmax > linthresh :
2423
2424
has_c = True
2424
2425
else :
2425
2426
return [vmin , vmax ]
2426
- elif vmin < t :
2427
- if vmax > t :
2427
+ elif vmin < linthresh :
2428
+ if vmax > linthresh :
2428
2429
has_b = True
2429
2430
has_c = True
2430
2431
else :
@@ -2433,46 +2434,47 @@ def tick_values(self, vmin, vmax):
2433
2434
has_c = True
2434
2435
2435
2436
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 ))
2438
2439
return lo , hi
2439
2440
2440
- # First, calculate all the ranges, so we can determine striding
2441
+ # Calculate all the ranges, so we can determine striding
2441
2442
if has_a :
2442
2443
if has_b :
2443
- a_range = get_log_range (t , - vmin + 1 )
2444
+ a_range = get_log_range (linthresh , np . abs ( vmin ) + 1 )
2444
2445
else :
2445
- a_range = get_log_range (- vmax , - vmin + 1 )
2446
+ a_range = get_log_range (np . abs ( vmax ), np . abs ( vmin ) + 1 )
2446
2447
else :
2447
2448
a_range = (0 , 0 )
2448
2449
2449
2450
if has_c :
2450
2451
if has_b :
2451
- c_range = get_log_range (t , vmax + 1 )
2452
+ c_range = get_log_range (linthresh , vmax + 1 )
2452
2453
else :
2453
2454
c_range = get_log_range (vmin , vmax + 1 )
2454
2455
else :
2455
2456
c_range = (0 , 0 )
2456
2457
2458
+ # Calculate the total number of integer exponents in a and c ranges
2457
2459
total_ticks = (a_range [1 ] - a_range [0 ]) + (c_range [1 ] - c_range [0 ])
2458
2460
if has_b :
2459
2461
total_ticks += 1
2460
2462
stride = max (total_ticks // (self .numticks - 1 ), 1 )
2461
2463
2462
2464
decades = []
2463
2465
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 ])))
2466
2468
2467
2469
if has_b :
2468
2470
decades .append (0.0 )
2469
2471
2470
2472
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 )))
2472
2474
2473
2475
# Add the subticks if requested
2474
2476
if self ._subs is None :
2475
- subs = np .arange (2.0 , b )
2477
+ subs = np .arange (2.0 , base )
2476
2478
else :
2477
2479
subs = np .asarray (self ._subs )
2478
2480
0 commit comments