()
| 93 | |
| 94 | |
| 95 | def 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 | |
| 130 | def test_figure_label(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…