File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 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):
29902990 if bb is None :
29912991 bb = ax .get_window_extent (renderer )
29922992 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
29932997 if top < 0 :
29942998 # the top of Axes is not even on the figure, so don't try and
29952999 # automatically place it.
Original file line number Diff line number Diff line change @@ -6121,6 +6121,16 @@ def test_title_xticks_top_both():
61216121 assert ax .title .get_position ()[1 ] > 1.04
61226122
61236123
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+
61246134def test_title_no_move_off_page ():
61256135 # If an axes is off the figure (ie. if it is cropped during a save)
61266136 # make sure that the automatic title repositioning does not get done.
You can’t perform that action at this time.
0 commit comments