|
17 | 17 | NonUniformImage, PcolorImage)
|
18 | 18 | from matplotlib.testing.decorators import check_figures_equal, image_comparison
|
19 | 19 | from matplotlib.transforms import Bbox, Affine2D, TransformedBbox
|
| 20 | +import matplotlib.ticker as mticker |
20 | 21 |
|
21 | 22 | import pytest
|
22 | 23 |
|
@@ -1218,3 +1219,36 @@ def test_huge_range_log(fig_test, fig_ref):
|
1218 | 1219 | ax = fig_ref.subplots()
|
1219 | 1220 | im = ax.imshow(data, norm=colors.Normalize(vmin=100, vmax=data.max()),
|
1220 | 1221 | interpolation='nearest', cmap=cmap)
|
| 1222 | + |
| 1223 | + |
| 1224 | +@check_figures_equal() |
| 1225 | +def test_spy_box(fig_test, fig_ref): |
| 1226 | + # setting up reference and test |
| 1227 | + ax_test = fig_test.subplots(1, 3) |
| 1228 | + ax_ref = fig_ref.subplots(1, 3) |
| 1229 | + |
| 1230 | + plot_data = ( |
| 1231 | + [[1, 1], [1, 1]], |
| 1232 | + [[0, 0], [0, 0]], |
| 1233 | + [[0, 1], [1, 0]], |
| 1234 | + ) |
| 1235 | + plot_titles = ["ones", "zeros", "mixed"] |
| 1236 | + |
| 1237 | + for i, (z, title) in enumerate(zip(plot_data, plot_titles)): |
| 1238 | + ax_test[i].set_title(title) |
| 1239 | + ax_test[i].spy(z) |
| 1240 | + ax_ref[i].set_title(title) |
| 1241 | + ax_ref[i].imshow(z, interpolation='nearest', |
| 1242 | + aspect='equal', origin='upper', cmap='Greys', |
| 1243 | + vmin=0, vmax=1) |
| 1244 | + ax_ref[i].set_xlim(-0.5, 1.5) |
| 1245 | + ax_ref[i].set_ylim(1.5, -0.5) |
| 1246 | + ax_ref[i].xaxis.tick_top() |
| 1247 | + ax_ref[i].title.set_y(1.05) |
| 1248 | + ax_ref[i].xaxis.set_ticks_position('both') |
| 1249 | + ax_ref[i].xaxis.set_major_locator( |
| 1250 | + mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True) |
| 1251 | + ) |
| 1252 | + ax_ref[i].yaxis.set_major_locator( |
| 1253 | + mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True) |
| 1254 | + ) |
0 commit comments