Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 32e67ef

Browse files
committed
FIX: new approach
1 parent 84286fc commit 32e67ef

File tree

3 files changed

+2
-12
lines changed

3 files changed

+2
-12
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ def set_title(self, label, fontdict=None, loc=None, pad=None, **kwargs):
171171
default["color"] = titlecolor
172172
if pad is None:
173173
pad = rcParams['axes.titlepad']
174-
self._autotitlepos = None
175-
else:
176-
self._autotitlepos = False
177174
self._set_title_offset_trans(float(pad))
178175
title.set_text(label)
179176
title.update(default)

lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2602,16 +2602,9 @@ def _update_title_position(self, renderer):
26022602
bb = ax.get_window_extent(renderer)
26032603
if bb is not None:
26042604
top = max(top, bb.ymax)
2605-
if title.get_window_extent(renderer).ymin < top:
2605+
if top > 0:
26062606
_, y = self.transAxes.inverted().transform((0, top))
26072607
title.set_position((x, y))
2608-
# empirically, this doesn't always get the min to top,
2609-
# so we need to adjust again.
2610-
if title.get_window_extent(renderer).ymin < top:
2611-
_, y = self.transAxes.inverted().transform(
2612-
(0., 2 * top - title.get_window_extent(renderer).ymin))
2613-
title.set_position((x, y))
2614-
26152608
ymax = max(title.get_position()[1] for title in titles)
26162609
for title in titles:
26172610
# now line up all the titles at the highest baseline.

lib/matplotlib/tests/test_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5479,7 +5479,7 @@ def test_title_noauto_pad():
54795479
assert ax.title.get_position()[1] == 1.0
54805480
ax.set_title(f"Title 2")
54815481
fig.canvas.draw()
5482-
assert ax.title.get_position()[1] > 1.04
5482+
assert ax.title.get_position()[1] == 1.0
54835483

54845484

54855485
def test_offset_label_color():

0 commit comments

Comments
 (0)