File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -2990,6 +2990,10 @@ def _update_title_position(self, renderer):
2990
2990
if bb is None :
2991
2991
bb = ax .get_window_extent (renderer )
2992
2992
top = max (top , bb .ymax )
2993
+ # take yaxis offset text into account
2994
+ bb = ax .yaxis .get_tightbbox (renderer )
2995
+ if ax .yaxis .offsetText .get_text () and bb .ymax > top :
2996
+ top = bb .ymax
2993
2997
if top < 0 :
2994
2998
# the top of Axes is not even on the figure, so don't try and
2995
2999
# automatically place it.
Original file line number Diff line number Diff line change @@ -6121,6 +6121,16 @@ def test_title_xticks_top_both():
6121
6121
assert ax .title .get_position ()[1 ] > 1.04
6122
6122
6123
6123
6124
+ def test_title_above_offset ():
6125
+ # Test that title moves if yaxis has offset text.
6126
+ mpl .rcParams ['axes.titley' ] = None
6127
+ fig , ax = plt .subplots ()
6128
+ ax .set_ylim (1e11 )
6129
+ ax .set_title ('Title' )
6130
+ fig .draw_without_rendering ()
6131
+ assert ax .title .get_position ()[1 ] > 1.0
6132
+
6133
+
6124
6134
def test_title_no_move_off_page ():
6125
6135
# If an axes is off the figure (ie. if it is cropped during a save)
6126
6136
# make sure that the automatic title repositioning does not get done.
You can’t perform that action at this time.
0 commit comments