| 1236 | @image_comparison(['imshow_clip'], style='mpl20', |
| 1237 | tol=0 if platform.machine() == 'x86_64' else 1.24) |
| 1238 | def test_imshow_clip(): |
| 1239 | # As originally reported by Gellule Xg <gellule.xg@free.fr> |
| 1240 | # use former defaults to match existing baseline image |
| 1241 | matplotlib.rcParams['image.interpolation'] = 'nearest' |
| 1242 | |
| 1243 | # Create an NxN image |
| 1244 | N = 100 |
| 1245 | (x, y) = np.indices((N, N)) |
| 1246 | x -= N//2 |
| 1247 | y -= N//2 |
| 1248 | r = np.sqrt(x**2+y**2-x*y) |
| 1249 | |
| 1250 | # Create a contour plot at N/4 and extract both the clip path and transform |
| 1251 | fig, ax = plt.subplots() |
| 1252 | |
| 1253 | c = ax.contour(r, [N/4]) |
| 1254 | clip_path = mtransforms.TransformedPath(c.get_paths()[0], c.get_transform()) |
| 1255 | |
| 1256 | # Plot the image clipped by the contour |
| 1257 | ax.imshow(r, clip_path=clip_path) |
| 1258 | |
| 1259 | |
| 1260 | def test_imshow_norm_vminvmax(): |