|
| 1 | +''' |
| 2 | +Show all different interpolation methods for imshow |
| 3 | +''' |
| 4 | + |
| 5 | +import matplotlib.pyplot as plt |
| 6 | +import numpy as np |
| 7 | + |
| 8 | +# from the docs: |
| 9 | + |
| 10 | +# If interpolation is None, default to rc image.interpolation. See also |
| 11 | +# the filternorm and filterrad parameters. If interpolation is 'none', then |
| 12 | +# no interpolation is performed on the Agg, ps and pdf backends. Other |
| 13 | +# backends will fall back to 'nearest'. |
| 14 | +# |
| 15 | +# http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.imshow |
| 16 | + |
| 17 | +methods = [None, 'none', 'nearest', 'bilinear', 'bicubic', 'spline16', |
| 18 | + 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', |
| 19 | + 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos'] |
| 20 | + |
| 21 | +grid = np.random.rand(4, 4) |
| 22 | + |
| 23 | +fig, axes = plt.subplots(3, 6, figsize=(12, 6), |
| 24 | + subplot_kw={'xticks': [], 'yticks': []}) |
| 25 | + |
| 26 | +fig.subplots_adjust(hspace=0.3, wspace=0.05) |
| 27 | + |
| 28 | +for ax, interp_method in zip(axes.flat, methods): |
| 29 | + ax.imshow(grid, interpolation=interp_method) |
| 30 | + ax.set_title(interp_method) |
| 31 | + |
| 32 | +plt.show() |
0 commit comments