File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2535,8 +2535,9 @@ def _update_title_position(self, renderer):
25352535 top = 0
25362536 for ax in axs :
25372537 try :
2538- if (ax .xaxis .get_label_position () == 'top'
2539- or ax .xaxis .get_ticks_position () == 'top' ):
2538+ choices = ['top' , 'unknown' ]
2539+ if (ax .xaxis .get_label_position () == 'top' or
2540+ ax .xaxis .get_ticks_position () in choices ):
25402541 bb = ax .xaxis .get_tightbbox (renderer )
25412542 else :
25422543 bb = ax .get_window_extent (renderer )
Original file line number Diff line number Diff line change @@ -5723,6 +5723,16 @@ def test_title_xticks_top():
57235723 assert ax .title .get_position ()[1 ] > 1.04
57245724
57255725
5726+ def test_title_xticks_top_both ():
5727+ # Test that title moves if xticks on top of axes.
5728+ fig , ax = plt .subplots ()
5729+ ax .tick_params (axis = "x" , bottom = True , top = True ,
5730+ labelbottom = True , labeltop = True )
5731+ ax .set_title ('xlabel top' )
5732+ fig .canvas .draw ()
5733+ assert ax .title .get_position ()[1 ] > 1.04
5734+
5735+
57265736def test_offset_label_color ():
57275737 # Tests issue 6440
57285738 fig = plt .figure ()
You can’t perform that action at this time.
0 commit comments