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 20387f7

Browse filesBrowse files
authored
Merge pull request #13741 from jklymak/fix-move-title-ticklabels
FIX: make title move above ticklabels
2 parents e974bf0 + b4a1a97 commit 20387f7
Copy full SHA for 20387f7

File tree

Expand file treeCollapse file tree

2 files changed

+13
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-2
lines changed

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2535,8 +2535,9 @@ def _update_title_position(self, renderer):
25352535
top = 0
25362536
for ax in axs:
25372537
try:
2538-
if (ax.xaxis.get_label_position() == 'top'
2539-
or ax.xaxis.get_ticks_position() == 'top'):
2538+
choices = ['top', 'unknown']
2539+
if (ax.xaxis.get_label_position() == 'top' or
2540+
ax.xaxis.get_ticks_position() in choices):
25402541
bb = ax.xaxis.get_tightbbox(renderer)
25412542
else:
25422543
bb = ax.get_window_extent(renderer)

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5723,6 +5723,16 @@ def test_title_xticks_top():
57235723
assert ax.title.get_position()[1] > 1.04
57245724

57255725

5726+
def test_title_xticks_top_both():
5727+
# Test that title moves if xticks on top of axes.
5728+
fig, ax = plt.subplots()
5729+
ax.tick_params(axis="x", bottom=True, top=True,
5730+
labelbottom=True, labeltop=True)
5731+
ax.set_title('xlabel top')
5732+
fig.canvas.draw()
5733+
assert ax.title.get_position()[1] > 1.04
5734+
5735+
57265736
def test_offset_label_color():
57275737
# Tests issue 6440
57285738
fig = plt.figure()

0 commit comments

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