From 18a27472396aa1222ff74571b660d942299f3afd Mon Sep 17 00:00:00 2001 From: Egor Panfilov Date: Thu, 24 Dec 2015 18:17:28 +0300 Subject: [PATCH] DOC: plot_edge_modes improvement, closes #1816 --- doc/examples/transform/plot_edge_modes.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/doc/examples/transform/plot_edge_modes.py b/doc/examples/transform/plot_edge_modes.py index 8689e4a8..9c583006 100644 --- a/doc/examples/transform/plot_edge_modes.py +++ b/doc/examples/transform/plot_edge_modes.py @@ -7,10 +7,10 @@ This example illustrates the different edge modes available during interpolation in routines such as `skimage.transform.rescale` and `skimage.transform.resize`. """ -from skimage._shared.interpolation import extend_image -import skimage.data -import matplotlib.pyplot as plt import numpy as np +import matplotlib.pyplot as plt + +from skimage._shared.interpolation import extend_image img = np.zeros((16, 16)) img[:8, :8] += 1 @@ -20,18 +20,19 @@ img[:1, :1] += 2 img[8, 8] = 4 modes = ['constant', 'edge', 'wrap', 'reflect', 'symmetric'] -fig, axes = plt.subplots(1, 5, figsize=(15, 5)) +fig, axes = plt.subplots(2, 3) +axes = axes.flatten() + for n, mode in enumerate(modes): img_extended = extend_image(img, pad=img.shape[0], mode=mode) axes[n].imshow(img_extended, cmap=plt.cm.gray, interpolation='nearest') - axes[n].plot([15.5, 15.5], [15.5, 31.5], 'y--', linewidth=0.5) - axes[n].plot([31.5, 31.5], [15.5, 31.5], 'y--', linewidth=0.5) - axes[n].plot([15.5, 31.5], [15.5, 15.5], 'y--', linewidth=0.5) - axes[n].plot([15.5, 31.5], [31.5, 31.5], 'y--', linewidth=0.5) - axes[n].set_axis_off() - axes[n].set_aspect('equal') + axes[n].plot([15.5, 15.5, 31.5, 31.5, 15.5], + [15.5, 31.5, 31.5, 15.5, 15.5], 'y--', linewidth=0.5) axes[n].set_title(mode) +for n in range(len(axes)): + axes[n].set_axis_off() + axes[n].set_aspect('equal') + plt.tight_layout() - plt.show()