| 688 | |
| 689 | @mpl.style.context('default') |
| 690 | def test_use_sticky_edges(): |
| 691 | fig, ax = plt.subplots() |
| 692 | ax.imshow([[0, 1], [2, 3]], origin='lower') |
| 693 | assert_allclose(ax.get_xlim(), (-0.5, 1.5)) |
| 694 | assert_allclose(ax.get_ylim(), (-0.5, 1.5)) |
| 695 | ax.use_sticky_edges = False |
| 696 | ax.autoscale() |
| 697 | xlim = (-0.5 - 2 * ax._xmargin, 1.5 + 2 * ax._xmargin) |
| 698 | ylim = (-0.5 - 2 * ax._ymargin, 1.5 + 2 * ax._ymargin) |
| 699 | assert_allclose(ax.get_xlim(), xlim) |
| 700 | assert_allclose(ax.get_ylim(), ylim) |
| 701 | # Make sure it is reversible: |
| 702 | ax.use_sticky_edges = True |
| 703 | ax.autoscale() |
| 704 | assert_allclose(ax.get_xlim(), (-0.5, 1.5)) |
| 705 | assert_allclose(ax.get_ylim(), (-0.5, 1.5)) |
| 706 | |
| 707 | |
| 708 | @check_figures_equal() |