From cc56d0aa3641cce8632b37b3d60a5be3eb5d8891 Mon Sep 17 00:00:00 2001 From: RutgerK Date: Mon, 18 Nov 2013 09:13:30 +0100 Subject: [PATCH 1/5] Create interpolation_methods.py --- examples/api/interpolation_methods.py | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 examples/api/interpolation_methods.py diff --git a/examples/api/interpolation_methods.py b/examples/api/interpolation_methods.py new file mode 100644 index 000000000000..65b07fa5cf2b --- /dev/null +++ b/examples/api/interpolation_methods.py @@ -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, ax = plt.subplots(3,6,figsize=(12,6), subplot_kw={'xticks': [], 'yticks': []}) +fig.subplots_adjust(hspace=0.3, wspace=0.05) + +ax = ax.ravel() + +for n, interp in enumerate(methods): + ax[n].imshow(grid, interpolation=interp) + ax[n].set_title(interp) + +plt.show() From 40cd8c20223b49cc02f66fb13c5beba709ab9e59 Mon Sep 17 00:00:00 2001 From: RutgerK Date: Mon, 18 Nov 2013 13:21:00 +0100 Subject: [PATCH 2/5] Rename examples/api/interpolation_methods.py to examples/images_contours_and_fields/interpolation_methods.py --- .../{api => images_contours_and_fields}/interpolation_methods.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/{api => images_contours_and_fields}/interpolation_methods.py (100%) diff --git a/examples/api/interpolation_methods.py b/examples/images_contours_and_fields/interpolation_methods.py similarity index 100% rename from examples/api/interpolation_methods.py rename to examples/images_contours_and_fields/interpolation_methods.py From 962ed31483668d496aece83187af24b460fc370c Mon Sep 17 00:00:00 2001 From: RutgerK Date: Mon, 18 Nov 2013 13:21:36 +0100 Subject: [PATCH 3/5] Update interpolation_methods.py --- .../interpolation_methods.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/images_contours_and_fields/interpolation_methods.py b/examples/images_contours_and_fields/interpolation_methods.py index 65b07fa5cf2b..bf3947888dba 100644 --- a/examples/images_contours_and_fields/interpolation_methods.py +++ b/examples/images_contours_and_fields/interpolation_methods.py @@ -8,19 +8,21 @@ # 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 +# 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'] +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) +grid = np.random.rand(4, 4) + +fig, ax = plt.subplots(3, 6, figsize=(12, 6), + subplot_kw={'xticks': [], 'yticks': []}) -fig, ax = plt.subplots(3,6,figsize=(12,6), subplot_kw={'xticks': [], 'yticks': []}) fig.subplots_adjust(hspace=0.3, wspace=0.05) ax = ax.ravel() From 8ee3f14cf77d4c51de60edf7d992f17a62924e67 Mon Sep 17 00:00:00 2001 From: RutgerK Date: Tue, 14 Jan 2014 16:38:22 +0100 Subject: [PATCH 4/5] Update interpolation_methods.py Update according Phils suggestion. --- examples/images_contours_and_fields/interpolation_methods.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/images_contours_and_fields/interpolation_methods.py b/examples/images_contours_and_fields/interpolation_methods.py index bf3947888dba..8e3b1f75810c 100644 --- a/examples/images_contours_and_fields/interpolation_methods.py +++ b/examples/images_contours_and_fields/interpolation_methods.py @@ -27,7 +27,7 @@ ax = ax.ravel() -for n, interp in enumerate(methods): +for ax, interp_method in zip(axes, methods): ax[n].imshow(grid, interpolation=interp) ax[n].set_title(interp) From 5e016636bb16162c8968f1bf9ec74a7eae69f4e2 Mon Sep 17 00:00:00 2001 From: RutgerK Date: Tue, 14 Jan 2014 16:57:17 +0100 Subject: [PATCH 5/5] Update interpolation_methods.py --- .../interpolation_methods.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/examples/images_contours_and_fields/interpolation_methods.py b/examples/images_contours_and_fields/interpolation_methods.py index 8e3b1f75810c..eda8cfa7efee 100644 --- a/examples/images_contours_and_fields/interpolation_methods.py +++ b/examples/images_contours_and_fields/interpolation_methods.py @@ -20,15 +20,13 @@ grid = np.random.rand(4, 4) -fig, ax = plt.subplots(3, 6, figsize=(12, 6), - subplot_kw={'xticks': [], 'yticks': []}) +fig, axes = plt.subplots(3, 6, figsize=(12, 6), + subplot_kw={'xticks': [], 'yticks': []}) fig.subplots_adjust(hspace=0.3, wspace=0.05) -ax = ax.ravel() - -for ax, interp_method in zip(axes, methods): - ax[n].imshow(grid, interpolation=interp) - ax[n].set_title(interp) +for ax, interp_method in zip(axes.flat, methods): + ax.imshow(grid, interpolation=interp_method) + ax.set_title(interp_method) plt.show()