Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 84286fc

Browse filesBrowse files
committed
TST: add test for pad turning off autopos
1 parent 5202a64 commit 84286fc
Copy full SHA for 84286fc

File tree

Expand file treeCollapse file tree

2 files changed

+15
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-0
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ 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
174175
else:
175176
self._autotitlepos = False
176177
self._set_title_offset_trans(float(pad))

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5468,6 +5468,20 @@ def test_title_xticks_top_both():
54685468
assert ax.title.get_position()[1] > 1.04
54695469

54705470

5471+
def test_title_noauto_pad():
5472+
# test that if we pad, then the title does not autopos
5473+
5474+
fig, ax = plt.subplots()
5475+
ax.set_title(f"Title 1", pad=-20)
5476+
ax.tick_params(axis="x",
5477+
bottom=True, top=True, labelbottom=True, labeltop=True)
5478+
fig.canvas.draw()
5479+
assert ax.title.get_position()[1] == 1.0
5480+
ax.set_title(f"Title 2")
5481+
fig.canvas.draw()
5482+
assert ax.title.get_position()[1] > 1.04
5483+
5484+
54715485
def test_offset_label_color():
54725486
# Tests issue 6440
54735487
fig = plt.figure()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.