@@ -2589,31 +2589,44 @@ class AsinhLocator(Locator):
25892589 """
25902590 An axis tick locator specialized for the inverse-sinh scale
25912591
2592- This is very unlikely to have any use beyond the AsinhScale class.
2592+ This is very unlikely to have any use beyond
2593+ the `~.scale.AsinhScale` class.
25932594 """
2594- def __init__ (self , linear_width , numticks = 11 ):
2595+ def __init__ (self , linear_width , numticks = 11 , symthresh = 0.2 ):
25952596 """
25962597 Parameters
25972598 ----------
25982599 linear_width : float
25992600 The scale parameter defining the extent
26002601 of the quasi-linear region.
2601- numticks : int, default: 12
2602+ numticks : int, default: 11
26022603 The approximate number of major ticks that will fit
26032604 along the entire axis
2605+ symthresh : float, default: 0.2
2606+ The fractional threshold beneath which data which covers
2607+ a range that is approximately symmetric about zero
2608+ will have ticks that are exactly symmetric.
26042609 """
26052610 super ().__init__ ()
26062611 self .linear_width = linear_width
26072612 self .numticks = numticks
2613+ self .symthresh = symthresh
26082614
2609- def set_params (self , numticks = None ):
2615+ def set_params (self , numticks = None , symthresh = None ):
26102616 """Set parameters within this locator."""
26112617 if numticks is not None :
26122618 self .numticks = numticks
2619+ if symthresh is not None :
2620+ self .symthresh = symthresh
26132621
26142622 def __call__ (self ):
26152623 dmin , dmax = self .axis .get_data_interval ()
2616- return self .tick_values (dmin , dmax )
2624+ if (dmin * dmax ) < 0 and abs (1 + dmax / dmin ) < self .symthresh :
2625+ # Data-range appears to be almost symmetric, so round up:
2626+ bound = max (abs (dmin ), abs (dmax ))
2627+ return self .tick_values (- bound , bound )
2628+ else :
2629+ return self .tick_values (dmin , dmax )
26172630
26182631 def tick_values (self , vmin , vmax ):
26192632 # Construct a set of "on-screen" locations
@@ -2622,9 +2635,9 @@ def tick_values(self, vmin, vmax):
26222635 / self .linear_width )
26232636 ys = np .linspace (ymin , ymax , self .numticks )
26242637 zero_dev = np .abs (ys / (ymax - ymin ))
2625- if (ymin * ymax ) < 0 and min (zero_dev ) > 1e-6 :
2638+ if (ymin * ymax ) < 0 and min (zero_dev ) > 0 :
26262639 # Ensure that the zero tick-mark is included,
2627- # if the axis stradles zero
2640+ # if the axis straddles zero
26282641 ys = np .hstack ([ys [(zero_dev > 0.5 / self .numticks )], 0.0 ])
26292642
26302643 # Transform the "on-screen" grid to the data space:
0 commit comments