File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -2663,7 +2663,7 @@ def _update_title_position(self, renderer):
2663
2663
bb = ax .get_window_extent (renderer )
2664
2664
if bb is not None :
2665
2665
top = max (top , bb .ymax )
2666
- if top < 0 or top > 1 :
2666
+ if top < 0 :
2667
2667
# the top of axes is not even on the figure, so don't try and
2668
2668
# automatically place it.
2669
2669
_log .debug ('top of axes not in the figure, so title not moved' )
Original file line number Diff line number Diff line change @@ -5533,6 +5533,19 @@ def test_title_xticks_top_both():
5533
5533
assert ax .title .get_position ()[1 ] > 1.04
5534
5534
5535
5535
5536
+ def test_title_no_move_off_page ():
5537
+ # If an axes is off the figure (ie. if it is cropped during a save)
5538
+ # make sure that the automatic title repositioning does not get done.
5539
+ mpl .rcParams ['axes.titley' ] = None
5540
+ fig = plt .figure ()
5541
+ ax = fig .add_axes ([0.1 , - 0.5 , 0.8 , 0.2 ])
5542
+ ax .tick_params (axis = "x" ,
5543
+ bottom = True , top = True , labelbottom = True , labeltop = True )
5544
+ tt = ax .set_title ('Boo' )
5545
+ fig .canvas .draw ()
5546
+ assert tt .get_position ()[1 ] == 1.0
5547
+
5548
+
5536
5549
def test_offset_label_color ():
5537
5550
# Tests issue 6440
5538
5551
fig = plt .figure ()
You can’t perform that action at this time.
0 commit comments