|
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,69 @@ 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 | + # plotting with spy |
| 1231 | + ax_test[0].set_title("ones") |
| 1232 | + ax_test[0].spy([[1, 1], [1, 1], ]) |
| 1233 | + ax_test[1].set_title("zeros") |
| 1234 | + ax_test[1].spy([[0, 0], [0, 0], ]) |
| 1235 | + ax_test[2].set_title("mixed") |
| 1236 | + ax_test[2].spy([[0, 1], [1, 0], ]) |
| 1237 | + |
| 1238 | + # plotting with imshow |
| 1239 | + ax_ref[0].set_title("ones") |
| 1240 | + ax_ref[0].imshow([[1, 1], [1, 1], ], interpolation='nearest', |
| 1241 | + aspect='equal', origin='upper', cmap='Greys', |
| 1242 | + vmin=0, vmax=1) |
| 1243 | + ax_ref[0].set_xlim(-0.5, 1.5) |
| 1244 | + ax_ref[0].set_ylim(1.5, -0.5) |
| 1245 | + ax_ref[0].xaxis.tick_top() |
| 1246 | + ax_ref[0].title.set_y(1.05) |
| 1247 | + ax_ref[0].xaxis.set_ticks_position('both') |
| 1248 | + ax_ref[0].xaxis.set_major_locator( |
| 1249 | + mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True) |
| 1250 | + ) |
| 1251 | + ax_ref[0].yaxis.set_major_locator( |
| 1252 | + mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True) |
| 1253 | + ) |
| 1254 | + |
| 1255 | + ax_ref[1].set_title("zeros") |
| 1256 | + ax_ref[1].imshow([[0, 0], [0, 0], ], interpolation='nearest', |
| 1257 | + aspect='equal', origin='upper', cmap='Greys', |
| 1258 | + vmin=0, vmax=1) |
| 1259 | + ax_ref[1].set_xlim(-0.5, 1.5) |
| 1260 | + ax_ref[1].set_ylim(1.5, -0.5) |
| 1261 | + ax_ref[1].xaxis.tick_top() |
| 1262 | + ax_ref[1].title.set_y(1.05) |
| 1263 | + ax_ref[1].xaxis.set_ticks_position('both') |
| 1264 | + ax_ref[1].xaxis.set_major_locator( |
| 1265 | + mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True) |
| 1266 | + ) |
| 1267 | + ax_ref[1].yaxis.set_major_locator( |
| 1268 | + mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True) |
| 1269 | + ) |
| 1270 | + |
| 1271 | + ax_ref[2].set_title("mixed") |
| 1272 | + ax_ref[2].imshow([[0, 1], [1, 0], ], interpolation='nearest', |
| 1273 | + aspect='equal', origin='upper', cmap='Greys', |
| 1274 | + vmin=0, vmax=1) |
| 1275 | + ax_ref[2].set_xlim(-0.5, 1.5) |
| 1276 | + ax_ref[2].set_ylim(1.5, -0.5) |
| 1277 | + ax_ref[2].xaxis.tick_top() |
| 1278 | + ax_ref[2].title.set_y(1.05) |
| 1279 | + ax_ref[2].xaxis.set_ticks_position('both') |
| 1280 | + ax_ref[2].xaxis.set_major_locator( |
| 1281 | + mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True) |
| 1282 | + ) |
| 1283 | + ax_ref[2].yaxis.set_major_locator( |
| 1284 | + mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True) |
| 1285 | + ) |
| 1286 | + |
| 1287 | + |
0 commit comments