@@ -2539,25 +2539,20 @@ def handle_single_axis(scale, autoscaleon, shared_axes, interval,
2539
2539
return # nothing to do...
2540
2540
2541
2541
shared = shared_axes .get_siblings (self )
2542
- dl = [ax .dataLim for ax in shared ]
2543
- # ignore non-finite data limits if good limits exist
2544
- finite_dl = [d for d in dl if np .isfinite (d ).all ()]
2545
- if len (finite_dl ):
2546
- # if finite limits exist for at least one axis (and the
2547
- # other is infinite), restore the finite limits
2548
- x_finite = [d for d in dl
2549
- if (np .isfinite (d .intervalx ).all () and
2550
- (d not in finite_dl ))]
2551
- y_finite = [d for d in dl
2552
- if (np .isfinite (d .intervaly ).all () and
2553
- (d not in finite_dl ))]
2554
-
2555
- dl = finite_dl
2556
- dl .extend (x_finite )
2557
- dl .extend (y_finite )
2558
-
2559
- bb = mtransforms .BboxBase .union (dl )
2560
- x0 , x1 = getattr (bb , interval )
2542
+ # Base autoscaling on finite data limits when there is at least one
2543
+ # finite data limit among all the shared_axes and intervals.
2544
+ # Also, find the minimum minpos for use in the margin calculation.
2545
+ x_values = []
2546
+ minimum_minpos = np .inf
2547
+ for ax in shared :
2548
+ x_values .extend (getattr (ax .dataLim , interval ))
2549
+ minimum_minpos = min (minimum_minpos ,
2550
+ getattr (ax .dataLim , minpos ))
2551
+ x_values = np .extract (np .isfinite (x_values ), x_values )
2552
+ if x_values .size >= 1 :
2553
+ x0 , x1 = (x_values .min (), x_values .max ())
2554
+ else :
2555
+ x0 , x1 = (- np .inf , np .inf )
2561
2556
# If x0 and x1 are non finite, use the locator to figure out
2562
2557
# default limits.
2563
2558
locator = axis .get_major_locator ()
@@ -2578,10 +2573,9 @@ def handle_single_axis(scale, autoscaleon, shared_axes, interval,
2578
2573
2579
2574
# Add the margin in figure space and then transform back, to handle
2580
2575
# non-linear scales.
2581
- minpos = getattr (bb , minpos )
2582
2576
transform = axis .get_transform ()
2583
2577
inverse_trans = transform .inverted ()
2584
- x0 , x1 = axis ._scale .limit_range_for_scale (x0 , x1 , minpos )
2578
+ x0 , x1 = axis ._scale .limit_range_for_scale (x0 , x1 , minimum_minpos )
2585
2579
x0t , x1t = transform .transform ([x0 , x1 ])
2586
2580
delta = (x1t - x0t ) * margin
2587
2581
if not np .isfinite (delta ):
0 commit comments