MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_align_titles

Function test_align_titles

lib/matplotlib/tests/test_figure.py:73–92  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

71 'figure_align_titles_constrained.png'],
72 style='mpl20', tol=0 if platform.machine() == 'x86_64' else 0.021)
73def 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
95def test_align_labels_stray_axes():

Callers

nothing calls this directly

Calls 8

set_xlabelMethod · 0.80
tick_topMethod · 0.80
set_rotationMethod · 0.80
align_titlesMethod · 0.80
subplotsMethod · 0.45
plotMethod · 0.45
set_titleMethod · 0.45
set_label_positionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…