@@ -2545,15 +2545,17 @@ def handle_single_axis(scale, autoscaleon, shared_axes, interval,
2545
2545
locator = axis .get_major_locator ()
2546
2546
x0 , x1 = locator .nonsingular (x0 , x1 )
2547
2547
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 ))
2552
2554
# Index of largest element < x0 + tol, if any.
2553
- i0 = stickies .searchsorted (x0 + tol ( x0 ) ) - 1
2555
+ i0 = stickies .searchsorted (x0 + tol ) - 1
2554
2556
x0bound = stickies [i0 ] if i0 != - 1 else None
2555
2557
# Index of smallest element > x1 - tol, if any.
2556
- i1 = stickies .searchsorted (x1 - tol ( x1 ) )
2558
+ i1 = stickies .searchsorted (x1 - tol )
2557
2559
x1bound = stickies [i1 ] if i1 != len (stickies ) else None
2558
2560
2559
2561
# Add the margin in figure space and then transform back, to handle
0 commit comments