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

Commit5e09660

Browse files
committed
Add unit test for align_titles
1 parent497e1cf commit5e09660

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed
34.3 KB
Loading
33 KB
Loading

‎lib/matplotlib/tests/test_figure.py‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,54 @@ def test_align_labels():
6666
fig.align_labels()
6767

6868

69+
@image_comparison(['figure_align_titles_constrained'],extensions=['png'],
70+
tol=0ifplatform.machine()=='x86_64'else0.01,
71+
style='mpl20')
72+
deftest_align_titles_constrained():
73+
fig,axs=plt.subplots(1,2,layout='constrained',width_ratios=[2,1])
74+
75+
ax=axs[0]
76+
ax.plot(np.arange(0,1e6,1000))
77+
ax.set_title('Title0 left',loc='left')
78+
ax.set_title('Title0 center',loc='center')
79+
ax.set_title('Title0 right',loc='right')
80+
81+
ax=axs[1]
82+
ax.plot(np.arange(0,1e4,100))
83+
ax.set_title('Title1')
84+
ax.set_xlabel('Xlabel0')
85+
ax.xaxis.set_label_position("top")
86+
ax.xaxis.tick_top()
87+
fortickinax.get_xticklabels():
88+
tick.set_rotation(90)
89+
90+
fig.align_titles()
91+
92+
93+
@image_comparison(['figure_align_titles_tight'],extensions=['png'],
94+
tol=0ifplatform.machine()=='x86_64'else0.01,
95+
style='mpl20')
96+
deftest_align_titles_tight():
97+
fig,axs=plt.subplots(1,2,layout='tight',width_ratios=[2,1])
98+
99+
ax=axs[0]
100+
ax.plot(np.arange(0,1e6,1000))
101+
ax.set_title('Title0 left',loc='left')
102+
ax.set_title('Title0 center',loc='center')
103+
ax.set_title('Title0 right',loc='right')
104+
105+
ax=axs[1]
106+
ax.plot(np.arange(0,1e4,100))
107+
ax.set_title('Title1')
108+
ax.set_xlabel('Xlabel0')
109+
ax.xaxis.set_label_position("top")
110+
ax.xaxis.tick_top()
111+
fortickinax.get_xticklabels():
112+
tick.set_rotation(90)
113+
114+
fig.align_titles()
115+
116+
69117
deftest_align_labels_stray_axes():
70118
fig,axs=plt.subplots(2,2)
71119
fornn,axinenumerate(axs.flat):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp