@@ -2514,10 +2514,8 @@ def _update_title_position(self, renderer):
2514
2514
return
2515
2515
self ._autotitlepos = True
2516
2516
2517
- ymax = - 10
2518
2517
for title in titles :
2519
- x , y0 = title .get_position ()
2520
- y = 1
2518
+ x , _ = title .get_position ()
2521
2519
# need to start again in case of window resizing
2522
2520
title .set_position ((x , 1.0 ))
2523
2521
# need to check all our twins too...
@@ -2534,31 +2532,27 @@ def _update_title_position(self, renderer):
2534
2532
axs = axs + [ax ]
2535
2533
top = 0
2536
2534
for ax in axs :
2537
- try :
2538
- choices = ['top' , 'unknown' ]
2539
- if (ax .xaxis .get_label_position () == 'top' or
2540
- ax .xaxis .get_ticks_position () in choices ):
2541
- bb = ax .xaxis .get_tightbbox (renderer )
2542
- else :
2543
- bb = ax .get_window_extent (renderer )
2535
+ if (ax .xaxis .get_ticks_position () in ['top' , 'unknown' ]
2536
+ or ax .xaxis .get_label_position () == 'top' ):
2537
+ bb = ax .xaxis .get_tightbbox (renderer )
2538
+ else :
2539
+ bb = ax .get_window_extent (renderer )
2540
+ if bb is not None :
2544
2541
top = max (top , bb .ymax )
2545
- except AttributeError :
2546
- # this happens for an empty bb
2547
- y = 1
2548
2542
if title .get_window_extent (renderer ).ymin < top :
2549
- y = self .transAxes .inverted ().transform (
2550
- (0. , top ))[1 ]
2543
+ _ , y = self .transAxes .inverted ().transform ((0 , top ))
2551
2544
title .set_position ((x , y ))
2552
2545
# empirically, this doesn't always get the min to top,
2553
2546
# so we need to adjust again.
2554
2547
if title .get_window_extent (renderer ).ymin < top :
2555
2548
_ , y = self .transAxes .inverted ().transform (
2556
2549
(0. , 2 * top - title .get_window_extent (renderer ).ymin ))
2557
2550
title .set_position ((x , y ))
2558
- ymax = max (y , ymax )
2551
+
2552
+ ymax = max (title .get_position ()[1 ] for title in titles )
2559
2553
for title in titles :
2560
2554
# now line up all the titles at the highest baseline.
2561
- x , y0 = title .get_position ()
2555
+ x , _ = title .get_position ()
2562
2556
title .set_position ((x , ymax ))
2563
2557
2564
2558
# Drawing
0 commit comments