|
| 1 | +import matplotlib.ticker as mticker |
| 2 | +from matplotlib import pyplot as plt |
| 3 | +from matplotlib.testing.decorators import check_figures_equal |
| 4 | + |
| 5 | + |
| 6 | +@check_figures_equal() |
| 7 | +def test_spy_box(fig_test, fig_ref): |
| 8 | + # setting up reference and test |
| 9 | + ax_test = fig_test.subplots(1, 3) |
| 10 | + ax_ref = fig_ref.subplots(1, 3) |
| 11 | + |
| 12 | + # plotting with spy |
| 13 | + ax_test[0].set_title("ones") |
| 14 | + ax_test[0].spy([[1, 1], [1, 1], ]) |
| 15 | + ax_test[1].set_title("zeros") |
| 16 | + ax_test[1].spy([[0, 0], [0, 0], ]) |
| 17 | + ax_test[2].set_title("mixed") |
| 18 | + ax_test[2].spy([[0, 1], [1, 0], ]) |
| 19 | + |
| 20 | + # plotting with imshow |
| 21 | + ax_ref[0].set_title("ones") |
| 22 | + ax_ref[0].imshow([[1, 1], [1, 1], ], interpolation='nearest', |
| 23 | + aspect='equal', origin='upper', cmap='Greys', |
| 24 | + vmin=0, vmax=1) |
| 25 | + ax_ref[0].set_xlim(-0.5, 1.5) |
| 26 | + ax_ref[0].set_ylim(1.5, -0.5) |
| 27 | + ax_ref[0].xaxis.tick_top() |
| 28 | + ax_ref[0].title.set_y(1.05) |
| 29 | + ax_ref[0].xaxis.set_ticks_position('both') |
| 30 | + ax_ref[0].xaxis.set_major_locator( |
| 31 | + mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True) |
| 32 | + ) |
| 33 | + ax_ref[0].yaxis.set_major_locator( |
| 34 | + mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True) |
| 35 | + ) |
| 36 | + |
| 37 | + ax_ref[1].set_title("zeros") |
| 38 | + ax_ref[1].imshow([[0, 0], [0, 0], ], interpolation='nearest', |
| 39 | + aspect='equal', origin='upper', cmap='Greys', |
| 40 | + vmin=0, vmax=1) |
| 41 | + ax_ref[1].set_xlim(-0.5, 1.5) |
| 42 | + ax_ref[1].set_ylim(1.5, -0.5) |
| 43 | + ax_ref[1].xaxis.tick_top() |
| 44 | + ax_ref[1].title.set_y(1.05) |
| 45 | + ax_ref[1].xaxis.set_ticks_position('both') |
| 46 | + ax_ref[1].xaxis.set_major_locator( |
| 47 | + mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True) |
| 48 | + ) |
| 49 | + ax_ref[1].yaxis.set_major_locator( |
| 50 | + mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True) |
| 51 | + ) |
| 52 | + |
| 53 | + ax_ref[2].set_title("mixed") |
| 54 | + ax_ref[2].imshow([[0, 1], [1, 0], ], interpolation='nearest', |
| 55 | + aspect='equal', origin='upper', cmap='Greys', |
| 56 | + vmin=0, vmax=1) |
| 57 | + ax_ref[2].set_xlim(-0.5, 1.5) |
| 58 | + ax_ref[2].set_ylim(1.5, -0.5) |
| 59 | + ax_ref[2].xaxis.tick_top() |
| 60 | + ax_ref[2].title.set_y(1.05) |
| 61 | + ax_ref[2].xaxis.set_ticks_position('both') |
| 62 | + ax_ref[2].xaxis.set_major_locator( |
| 63 | + mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True) |
| 64 | + ) |
| 65 | + ax_ref[2].yaxis.set_major_locator( |
| 66 | + mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True) |
| 67 | + ) |
| 68 | + |
| 69 | + |
0 commit comments