@@ -2514,10 +2514,8 @@ def _update_title_position(self, renderer):
25142514 return
25152515 self ._autotitlepos = True
25162516
2517- ymax = - 10
25182517 for title in titles :
2519- x , y0 = title .get_position ()
2520- y = 1
2518+ x , _ = title .get_position ()
25212519 # need to start again in case of window resizing
25222520 title .set_position ((x , 1.0 ))
25232521 # need to check all our twins too...
@@ -2534,31 +2532,27 @@ def _update_title_position(self, renderer):
25342532 axs = axs + [ax ]
25352533 top = 0
25362534 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 :
25442541 top = max (top , bb .ymax )
2545- except AttributeError :
2546- # this happens for an empty bb
2547- y = 1
25482542 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 ))
25512544 title .set_position ((x , y ))
25522545 # empirically, this doesn't always get the min to top,
25532546 # so we need to adjust again.
25542547 if title .get_window_extent (renderer ).ymin < top :
25552548 _ , y = self .transAxes .inverted ().transform (
25562549 (0. , 2 * top - title .get_window_extent (renderer ).ymin ))
25572550 title .set_position ((x , y ))
2558- ymax = max (y , ymax )
2551+
2552+ ymax = max (title .get_position ()[1 ] for title in titles )
25592553 for title in titles :
25602554 # now line up all the titles at the highest baseline.
2561- x , y0 = title .get_position ()
2555+ x , _ = title .get_position ()
25622556 title .set_position ((x , ymax ))
25632557
25642558 # Drawing
0 commit comments