Test automatic use of tight_layout.
()
| 154 | |
| 155 | |
| 156 | def test_outward_ticks(): |
| 157 | """Test automatic use of tight_layout.""" |
| 158 | fig = plt.figure() |
| 159 | ax = fig.add_subplot(221) |
| 160 | ax.xaxis.set_tick_params(tickdir='out', length=16, width=3) |
| 161 | ax.yaxis.set_tick_params(tickdir='out', length=16, width=3) |
| 162 | ax.xaxis.set_tick_params( |
| 163 | tickdir='out', length=32, width=3, tick1On=True, which='minor') |
| 164 | ax.yaxis.set_tick_params( |
| 165 | tickdir='out', length=32, width=3, tick1On=True, which='minor') |
| 166 | ax.xaxis.set_ticks([0], minor=True) |
| 167 | ax.yaxis.set_ticks([0], minor=True) |
| 168 | ax = fig.add_subplot(222) |
| 169 | ax.xaxis.set_tick_params(tickdir='in', length=32, width=3) |
| 170 | ax.yaxis.set_tick_params(tickdir='in', length=32, width=3) |
| 171 | ax = fig.add_subplot(223) |
| 172 | ax.xaxis.set_tick_params(tickdir='inout', length=32, width=3) |
| 173 | ax.yaxis.set_tick_params(tickdir='inout', length=32, width=3) |
| 174 | ax = fig.add_subplot(224) |
| 175 | ax.xaxis.set_tick_params(tickdir='out', length=32, width=3) |
| 176 | ax.yaxis.set_tick_params(tickdir='out', length=32, width=3) |
| 177 | plt.tight_layout() |
| 178 | # These values were obtained after visual checking that they correspond |
| 179 | # to a tight layouting that did take the ticks into account. |
| 180 | expected = [ |
| 181 | [[0.092, 0.605], [0.433, 0.933]], |
| 182 | [[0.581, 0.605], [0.922, 0.933]], |
| 183 | [[0.092, 0.138], [0.433, 0.466]], |
| 184 | [[0.581, 0.138], [0.922, 0.466]], |
| 185 | ] |
| 186 | for nn, ax in enumerate(fig.axes): |
| 187 | assert_array_equal(np.round(ax.get_position().get_points(), 3), |
| 188 | expected[nn]) |
| 189 | |
| 190 | |
| 191 | def add_offsetboxes(ax, size=10, margin=.1, color='black'): |
nothing calls this directly
no test coverage detected
searching dependent graphs…