@@ -2545,15 +2545,17 @@ def handle_single_axis(scale, autoscaleon, shared_axes, interval,
25452545 locator = axis .get_major_locator ()
25462546 x0 , x1 = locator .nonsingular (x0 , x1 )
25472547
2548- # Prevent margin addition from crossing a sticky value. Small
2549- # tolerances (whose values come from isclose()) must be used due to
2550- # floating point issues with streamplot.
2551- def tol (x ): return 1e-5 * abs (x ) + 1e-8
2548+ # Prevent margin addition from crossing a sticky value. A small
2549+ # tolerance must be added due to floating point issues with
2550+ # streamplot; it is defined relative to x0, x1, x1-x0 but has
2551+ # no absolute term (e.g. "+1e-8") to avoid issues when working with
2552+ # datasets where all values are tiny (less than 1e-8).
2553+ tol = 1e-5 * max (abs (x0 ), abs (x1 ), abs (x1 - x0 ))
25522554 # Index of largest element < x0 + tol, if any.
2553- i0 = stickies .searchsorted (x0 + tol ( x0 ) ) - 1
2555+ i0 = stickies .searchsorted (x0 + tol ) - 1
25542556 x0bound = stickies [i0 ] if i0 != - 1 else None
25552557 # Index of smallest element > x1 - tol, if any.
2556- i1 = stickies .searchsorted (x1 - tol ( x1 ) )
2558+ i1 = stickies .searchsorted (x1 - tol )
25572559 x1bound = stickies [i1 ] if i1 != len (stickies ) else None
25582560
25592561 # Add the margin in figure space and then transform back, to handle
0 commit comments