Skip to content

Commit 6c8e5d5

Browse files
committed
Add unit test for align_titles
1 parent 497e1cf commit 6c8e5d5

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

lib/matplotlib/tests/test_figure.py

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

6868

69+
@image_comparison(['figure_align_titles_tight.png',
70+
'figure_align_titles_constrained.png'],
71+
tol=0 if platform.machine() == 'x86_64' else 0.01,
72+
style='mpl20')
73+
def test_align_titles():
74+
for layout in ['tight', 'constrained']:
75+
fig, axs = plt.subplots(1, 2, layout=layout, width_ratios=[2, 1])
76+
77+
ax = axs[0]
78+
ax.plot(np.arange(0, 1e6, 1000))
79+
ax.set_title('Title0 left', loc='left')
80+
ax.set_title('Title0 center', loc='center')
81+
ax.set_title('Title0 right', loc='right')
82+
83+
ax = axs[1]
84+
ax.plot(np.arange(0, 1e4, 100))
85+
ax.set_title('Title1')
86+
ax.set_xlabel('Xlabel0')
87+
ax.xaxis.set_label_position("top")
88+
ax.xaxis.tick_top()
89+
for tick in ax.get_xticklabels():
90+
tick.set_rotation(90)
91+
92+
fig.align_titles()
93+
94+
6995
def test_align_labels_stray_axes():
7096
fig, axs = plt.subplots(2, 2)
7197
for nn, ax in enumerate(axs.flat):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy