@@ -2592,7 +2592,8 @@ class AsinhLocator(Locator):
25922592 This is very unlikely to have any use beyond
25932593 the `~.scale.AsinhScale` class.
25942594 """
2595- def __init__ (self , linear_width , numticks = 11 , symthresh = 0.2 ):
2595+ def __init__ (self , linear_width , numticks = 11 , symthresh = 0.2 ,
2596+ base = 0 , subs = None ):
25962597 """
25972598 Parameters
25982599 ----------
@@ -2611,6 +2612,8 @@ def __init__(self, linear_width, numticks=11, symthresh=0.2):
26112612 self .linear_width = linear_width
26122613 self .numticks = numticks
26132614 self .symthresh = symthresh
2615+ self .base = base
2616+ self .subs = subs
26142617
26152618 def set_params (self , numticks = None , symthresh = None ):
26162619 """Set parameters within this locator."""
@@ -2642,19 +2645,33 @@ def tick_values(self, vmin, vmax):
26422645
26432646 # Transform the "on-screen" grid to the data space:
26442647 xs = self .linear_width * np .sinh (ys / self .linear_width )
2645- zero_xs = (xs == 0 )
2646-
2647- # Round the data-space values to be intuitive decimal numbers:
2648- decades = (
2649- np .where (xs >= 0 , 1 , - 1 ) *
2650- np .power (10 , np .where (zero_xs , 0.0 ,
2651- np .floor (np .log10 (np .abs (xs )
2652- + zero_xs * 1e-6 ))))
2653- )
2654- qs = decades * np .round (xs / decades )
2648+ zero_xs = (ys == 0 )
2649+
2650+ # Round the data-space values to be intuitive base-n numbers:
2651+ if self .base > 1 :
2652+ log_base = math .log (self .base )
2653+ powers = (
2654+ np .where (zero_xs , 0 , np .where (xs >= 0 , 1 , - 1 )) *
2655+ np .power (self .base ,
2656+ np .where (zero_xs , 0.0 ,
2657+ np .floor (np .log (np .abs (xs ) + zero_xs * 1e-6 )
2658+ / log_base )))
2659+ )
2660+ if self .subs :
2661+ qs = np .outer (powers , self .subs ).flatten ()
2662+ else :
2663+ qs = powers
2664+ else :
2665+ powers = (
2666+ np .where (xs >= 0 , 1 , - 1 ) *
2667+ np .power (10 , np .where (zero_xs , 0.0 ,
2668+ np .floor (np .log10 (np .abs (xs )
2669+ + zero_xs * 1e-6 ))))
2670+ )
2671+ qs = powers * np .round (xs / powers )
26552672 ticks = np .array (sorted (set (qs )))
26562673
2657- if len (ticks ) > self . numticks // 2 :
2674+ if len (ticks ) >= 2 :
26582675 return ticks
26592676 else :
26602677 return np .linspace (vmin , vmax , self .numticks )
0 commit comments