File tree 2 files changed +13
-2
lines changed
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -2536,8 +2536,9 @@ def _update_title_position(self, renderer):
2536
2536
top = 0
2537
2537
for ax in axs :
2538
2538
try :
2539
- if (ax .xaxis .get_label_position () == 'top'
2540
- or ax .xaxis .get_ticks_position () == 'top' ):
2539
+ choices = ['top' , 'unknown' ]
2540
+ if (ax .xaxis .get_label_position () == 'top' or
2541
+ ax .xaxis .get_ticks_position () in choices ):
2541
2542
bb = ax .xaxis .get_tightbbox (renderer )
2542
2543
else :
2543
2544
bb = ax .get_window_extent (renderer )
Original file line number Diff line number Diff line change @@ -5724,6 +5724,16 @@ def test_title_xticks_top():
5724
5724
assert ax .title .get_position ()[1 ] > 1.04
5725
5725
5726
5726
5727
+ def test_title_xticks_top_both ():
5728
+ # Test that title moves if xticks on top of axes.
5729
+ fig , ax = plt .subplots ()
5730
+ ax .tick_params (axis = "x" , bottom = True , top = True ,
5731
+ labelbottom = True , labeltop = True )
5732
+ ax .set_title ('xlabel top' )
5733
+ fig .canvas .draw ()
5734
+ assert ax .title .get_position ()[1 ] > 1.04
5735
+
5736
+
5727
5737
def test_offset_label_color ():
5728
5738
# Tests issue 6440
5729
5739
fig = plt .figure ()
You can’t perform that action at this time.
0 commit comments