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

Function test_align_labels_stray_axes

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

Source from the content-addressed store, hash-verified

93
94
95def test_align_labels_stray_axes():
96 fig, axs = plt.subplots(2, 2)
97 for nn, ax in enumerate(axs.flat):
98 ax.set_xlabel('Boo')
99 ax.set_xlabel('Who')
100 ax.plot(np.arange(4)**nn, np.arange(4)**nn)
101 fig.align_ylabels()
102 fig.align_xlabels()
103 fig.draw_without_rendering()
104 xn = np.zeros(4)
105 yn = np.zeros(4)
106 for nn, ax in enumerate(axs.flat):
107 yn[nn] = ax.xaxis.label.get_position()[1]
108 xn[nn] = ax.yaxis.label.get_position()[0]
109 np.testing.assert_allclose(xn[:2], xn[2:])
110 np.testing.assert_allclose(yn[::2], yn[1::2])
111
112 fig, axs = plt.subplots(2, 2, constrained_layout=True)
113 for nn, ax in enumerate(axs.flat):
114 ax.set_xlabel('Boo')
115 ax.set_xlabel('Who')
116 pc = ax.pcolormesh(np.random.randn(10, 10))
117 fig.colorbar(pc, ax=ax)
118 fig.align_ylabels()
119 fig.align_xlabels()
120 fig.draw_without_rendering()
121 xn = np.zeros(4)
122 yn = np.zeros(4)
123 for nn, ax in enumerate(axs.flat):
124 yn[nn] = ax.xaxis.label.get_position()[1]
125 xn[nn] = ax.yaxis.label.get_position()[0]
126 np.testing.assert_allclose(xn[:2], xn[2:])
127 np.testing.assert_allclose(yn[::2], yn[1::2])
128
129
130def test_figure_label():

Callers

nothing calls this directly

Calls 9

set_xlabelMethod · 0.80
align_ylabelsMethod · 0.80
align_xlabelsMethod · 0.80
pcolormeshMethod · 0.80
subplotsMethod · 0.45
plotMethod · 0.45
get_positionMethod · 0.45
colorbarMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…