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

Function test_colorbar_align

lib/matplotlib/tests/test_constrainedlayout.py:440–469  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

438
439
440def test_colorbar_align():
441 for location in ['right', 'left', 'top', 'bottom']:
442 fig, axs = plt.subplots(2, 2, layout="constrained")
443 cbs = []
444 for nn, ax in enumerate(axs.flat):
445 ax.tick_params(direction='in')
446 pc = example_pcolor(ax)
447 cb = fig.colorbar(pc, ax=ax, location=location, shrink=0.6,
448 pad=0.04)
449 cbs += [cb]
450 cb.ax.tick_params(direction='in')
451 if nn != 1:
452 cb.ax.xaxis.set_ticks([])
453 cb.ax.yaxis.set_ticks([])
454 ax.set_xticklabels([])
455 ax.set_yticklabels([])
456 fig.get_layout_engine().set(w_pad=4 / 72, h_pad=4 / 72,
457 hspace=0.1, wspace=0.1)
458
459 fig.draw_without_rendering()
460 if location in ['left', 'right']:
461 np.testing.assert_allclose(cbs[0].ax.get_position().x0,
462 cbs[2].ax.get_position().x0)
463 np.testing.assert_allclose(cbs[1].ax.get_position().x0,
464 cbs[3].ax.get_position().x0)
465 else:
466 np.testing.assert_allclose(cbs[0].ax.get_position().y0,
467 cbs[1].ax.get_position().y0)
468 np.testing.assert_allclose(cbs[2].ax.get_position().y0,
469 cbs[3].ax.get_position().y0)
470
471
472@image_comparison(['test_colorbars_no_overlapV.png'], style='mpl20')

Callers

nothing calls this directly

Calls 9

example_pcolorFunction · 0.85
subplotsMethod · 0.45
tick_paramsMethod · 0.45
colorbarMethod · 0.45
set_ticksMethod · 0.45
setMethod · 0.45
get_layout_engineMethod · 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…