Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cc56d0a

Browse files
committed
Create interpolation_methods.py
1 parent 9290f57 commit cc56d0a

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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, ax = plt.subplots(3,6,figsize=(12,6), subplot_kw={'xticks': [], 'yticks': []})
24+
fig.subplots_adjust(hspace=0.3, wspace=0.05)
25+
26+
ax = ax.ravel()
27+
28+
for n, interp in enumerate(methods):
29+
ax[n].imshow(grid, interpolation=interp)
30+
ax[n].set_title(interp)
31+
32+
plt.show()

0 commit comments

Comments
 (0)