Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitb0d9f30

Browse files
committed
FIX: logic of title repositioning
1 parenta1eef38 commitb0d9f30

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

‎lib/matplotlib/axes/_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2981,13 +2981,13 @@ def _update_title_position(self, renderer):
29812981
axs=axs+ [ax]
29822982
top=-np.Inf
29832983
foraxinaxs:
2984+
bb=None
29842985
if (ax.xaxis.get_ticks_position()in ['top','unknown']
29852986
orax.xaxis.get_label_position()=='top'):
29862987
bb=ax.xaxis.get_tightbbox(renderer)
2987-
else:
2988+
ifbbisNone:
29882989
bb=ax.get_window_extent(renderer)
2989-
ifbbisnotNone:
2990-
top=max(top,bb.ymax)
2990+
top=max(top,bb.ymax)
29912991
iftop<0:
29922992
# the top of Axes is not even on the figure, so don't try and
29932993
# automatically place it.

‎lib/matplotlib/tests/test_axes.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5627,6 +5627,17 @@ def test_title_location_roundtrip():
56275627
ax.set_title('fail',loc='foo')
56285628

56295629

5630+
@pytest.mark.parametrize('sharex', [True,False])
5631+
deftest_title_location_shared(sharex):
5632+
fig,axs=plt.subplots(2,1,sharex=sharex)
5633+
axs[0].set_title('A',pad=-40)
5634+
axs[1].set_title('B',pad=-40)
5635+
fig.draw_without_rendering()
5636+
x,y1=axs[0].title.get_position()
5637+
x,y2=axs[1].title.get_position()
5638+
asserty1==y2==1.0
5639+
5640+
56305641
@image_comparison(["loglog.png"],remove_text=True,tol=0.02)
56315642
deftest_loglog():
56325643
fig,ax=plt.subplots()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp