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

Skip to content

Commit c154b90

Browse files
committed
Merge pull request #2599 from RutgerK/master
Create interpolation_methods.py
2 parents 80bba8e + 5e01663 commit c154b90

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
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, 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

Comments
 (0)