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

Function test_outward_ticks

lib/matplotlib/tests/test_tightlayout.py:156–188  ·  view source on GitHub ↗

Test automatic use of tight_layout.

()

Source from the content-addressed store, hash-verified

154
155
156def 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
191def add_offsetboxes(ax, size=10, margin=.1, color='black'):

Callers

nothing calls this directly

Calls 7

figureMethod · 0.80
add_subplotMethod · 0.80
set_tick_paramsMethod · 0.80
set_ticksMethod · 0.45
tight_layoutMethod · 0.45
get_pointsMethod · 0.45
get_positionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…