diff --git a/doc/examples/plot_local_otsu.py b/doc/examples/plot_local_otsu.py index aff7db62..ec3cdf48 100644 --- a/doc/examples/plot_local_otsu.py +++ b/doc/examples/plot_local_otsu.py @@ -37,28 +37,25 @@ threshold_global_otsu = threshold_otsu(img) global_otsu = img >= threshold_global_otsu -plt.figure(figsize=(8, 5)) +f, ax = plt.subplots(2, 2, figsize=(8, 5)) +ax1, ax2, ax3, ax4 = ax.ravel() -plt.subplot(2, 2, 1) -plt.imshow(img, cmap=plt.cm.gray) -plt.title('Original') -plt.colorbar(orientation='horizontal') -plt.axis('off') +f.colorbar(ax1.imshow(img, cmap=plt.cm.gray), + ax=ax1, orientation='horizontal') +ax1.set_title('Original') +ax1.axis('off') -plt.subplot(2, 2, 2) -plt.imshow(local_otsu, cmap=plt.cm.gray) -plt.title('Local Otsu (radius=%d)' % radius) -plt.colorbar(orientation='horizontal') -plt.axis('off') +f.colorbar(ax2.imshow(local_otsu, cmap=plt.cm.gray), + ax=ax2, orientation='horizontal') +ax2.set_title('Local Otsu (radius=%d)' % radius) +ax2.axis('off') -plt.subplot(2, 2, 3) -plt.imshow(img >= local_otsu, cmap=plt.cm.gray) -plt.title('Original >= Local Otsu' % threshold_global_otsu) -plt.axis('off') +ax3.imshow(img >= local_otsu, cmap=plt.cm.gray) +ax3.set_title('Original >= Local Otsu' % threshold_global_otsu) +ax3.axis('off') -plt.subplot(2, 2, 4) -plt.imshow(global_otsu, cmap=plt.cm.gray) -plt.title('Global Otsu (threshold = %d)' % threshold_global_otsu) -plt.axis('off') +ax4.imshow(global_otsu, cmap=plt.cm.gray) +ax4.set_title('Global Otsu (threshold = %d)' % threshold_global_otsu) +ax4.axis('off') plt.show() diff --git a/doc/examples/plot_phase_unwrap.py b/doc/examples/plot_phase_unwrap.py index 39055995..09c33f90 100644 --- a/doc/examples/plot_phase_unwrap.py +++ b/doc/examples/plot_phase_unwrap.py @@ -26,26 +26,20 @@ image_wrapped = np.angle(np.exp(1j * image)) # Perform phase unwrapping image_unwrapped = unwrap_phase(image_wrapped) -plt.figure() -plt.subplot(221) -plt.title('Original') -plt.imshow(image, cmap='gray', vmin=0, vmax=4 * np.pi) -plt.colorbar() +f, ax = plt.subplots(2, 2) +ax1, ax2, ax3, ax4 = ax.ravel() -plt.subplot(222) -plt.title('Wrapped phase') -plt.imshow(image_wrapped, cmap='gray', vmin=-np.pi, vmax=np.pi) -plt.colorbar() +f.colorbar(ax1.imshow(image, cmap='gray', vmin=0, vmax=4 * np.pi), ax=ax1) +ax1.set_title('Original') -plt.subplot(223) -plt.title('After phase unwrapping') -plt.imshow(image_unwrapped, cmap='gray') -plt.colorbar() +f.colorbar(ax2.imshow(image_wrapped, cmap='gray', vmin=-np.pi, vmax=np.pi), ax=ax2) +ax2.set_title('Wrapped phase') -plt.subplot(224) -plt.title('Unwrapped minus original') -plt.imshow(image_unwrapped - image, cmap='gray') -plt.colorbar() +f.colorbar(ax3.imshow(image_unwrapped, cmap='gray'), ax=ax3) +ax3.set_title('After phase unwrapping') + +f.colorbar(ax4.imshow(image_unwrapped - image, cmap='gray'), ax=ax4) +ax4.set_title('Unwrapped minus original') """ .. image:: PLOT2RST.current_figure @@ -70,26 +64,22 @@ image_unwrapped_no_wrap_around = unwrap_phase(image_wrapped, image_unwrapped_wrap_around = unwrap_phase(image_wrapped, wrap_around=(True, False)) -plt.figure() -plt.subplot(221) -plt.title('Original') -plt.imshow(np.ma.array(image, mask=mask), cmap='jet') -plt.colorbar() +f, ax = plt.subplots(2, 2) +ax1, ax2, ax3, ax4 = ax.ravel() -plt.subplot(222) -plt.title('Wrapped phase') -plt.imshow(image_wrapped, cmap='jet', vmin=-np.pi, vmax=np.pi) -plt.colorbar() +f.colorbar(ax1.imshow(np.ma.array(image, mask=mask), cmap='jet'), ax=ax1) +ax1.set_title('Original') -plt.subplot(223) -plt.title('Unwrapped without wrap_around') -plt.imshow(image_unwrapped_no_wrap_around, cmap='jet') -plt.colorbar() +f.colorbar(ax2.imshow(image_wrapped, cmap='jet', vmin=-np.pi, vmax=np.pi), + ax=ax2) +ax2.set_title('Wrapped phase') -plt.subplot(224) -plt.title('Unwrapped with wrap_around') -plt.imshow(image_unwrapped_wrap_around, cmap='jet') -plt.colorbar() +f.colorbar(ax3.imshow(image_unwrapped_no_wrap_around, cmap='jet'), + ax=ax3) +ax3.set_title('Unwrapped without wrap_around') + +f.colorbar(ax4.imshow(image_unwrapped_wrap_around, cmap='jet'), ax=ax4) +ax4.set_title('Unwrapped with wrap_around') plt.show()