()
| 438 | |
| 439 | |
| 440 | def 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') |
nothing calls this directly
no test coverage detected
searching dependent graphs…