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

Function test_twin_logscale

lib/matplotlib/tests/test_axes.py:402–441  ·  view source on GitHub ↗
(fig_test, fig_ref, twin)

Source from the content-addressed store, hash-verified

400@pytest.mark.parametrize('twin', ('x', 'y'))
401@check_figures_equal(tol=0.19)
402def test_twin_logscale(fig_test, fig_ref, twin):
403 twin_func = f'twin{twin}' # test twinx or twiny
404 set_scale = f'set_{twin}scale'
405 x = np.arange(1, 100)
406
407 # Change scale after twinning.
408 ax_test = fig_test.add_subplot(2, 1, 1)
409 ax_twin = getattr(ax_test, twin_func)()
410 getattr(ax_test, set_scale)('log')
411 ax_twin.plot(x, x)
412
413 # Twin after changing scale.
414 ax_test = fig_test.add_subplot(2, 1, 2)
415 getattr(ax_test, set_scale)('log')
416 ax_twin = getattr(ax_test, twin_func)()
417 ax_twin.plot(x, x)
418
419 for i in [1, 2]:
420 ax_ref = fig_ref.add_subplot(2, 1, i)
421 getattr(ax_ref, set_scale)('log')
422 ax_ref.plot(x, x)
423
424 # This is a hack because twinned Axes double-draw the frame.
425 # Remove this when that is fixed.
426 Path = matplotlib.path.Path
427 fig_ref.add_artist(
428 matplotlib.patches.PathPatch(
429 Path([[0, 0], [0, 1],
430 [0, 1], [1, 1],
431 [1, 1], [1, 0],
432 [1, 0], [0, 0]],
433 [Path.MOVETO, Path.LINETO] * 4),
434 transform=ax_ref.transAxes,
435 facecolor='none',
436 edgecolor=mpl.rcParams['axes.edgecolor'],
437 linewidth=mpl.rcParams['axes.linewidth'],
438 capstyle='projecting'))
439
440 remove_ticks_and_titles(fig_test)
441 remove_ticks_and_titles(fig_ref)
442
443
444@image_comparison(['twin_autoscale.png'], style='_classic_test',

Callers

nothing calls this directly

Calls 5

remove_ticks_and_titlesFunction · 0.90
PathClass · 0.85
add_subplotMethod · 0.80
plotMethod · 0.45
add_artistMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…