Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2599 from RutgerK/master
Create interpolation_methods.py
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
examples/images_contours_and_fields/interpolation_methods.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
''' | ||
Show all different interpolation methods for imshow | ||
''' | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
# from the docs: | ||
|
||
# If interpolation is None, default to rc image.interpolation. See also | ||
# the filternorm and filterrad parameters. If interpolation is 'none', then | ||
# no interpolation is performed on the Agg, ps and pdf backends. Other | ||
# backends will fall back to 'nearest'. | ||
# | ||
# http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.imshow | ||
|
||
methods = [None, 'none', 'nearest', 'bilinear', 'bicubic', 'spline16', | ||
'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', | ||
'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos'] | ||
|
||
grid = np.random.rand(4, 4) | ||
|
||
fig, axes = plt.subplots(3, 6, figsize=(12, 6), | ||
subplot_kw={'xticks': [], 'yticks': []}) | ||
|
||
fig.subplots_adjust(hspace=0.3, wspace=0.05) | ||
|
||
for ax, interp_method in zip(axes.flat, methods): | ||
ax.imshow(grid, interpolation=interp_method) | ||
ax.set_title(interp_method) | ||
|
||
plt.show() |