From 629a6b349c17d36f13de858946c50fcd815e3bf4 Mon Sep 17 00:00:00 2001 From: guanjihuan Date: Thu, 31 Mar 2022 23:22:37 +0800 Subject: [PATCH] 0.0.79 --- API_Reference/API_Reference.py | 7 ++- PyPI/setup.cfg | 2 +- PyPI/src/guan/__init__.py | 80 ++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 2 deletions(-) diff --git a/API_Reference/API_Reference.py b/API_Reference/API_Reference.py index 10b432c..4112026 100644 --- a/API_Reference/API_Reference.py +++ b/API_Reference/API_Reference.py @@ -239,7 +239,6 @@ guan.write_two_dimensional_data(x_array, y_array, matrix, filename='a', format=' - # plot figures guan.plot(x_array, y_array, xlabel='x', ylabel='y', title='', fontsize=20, labelsize=20, show=1, save=0, filename='a', format='jpg', dpi=300, type='', y_min=None, y_max=None, linewidth=None, markersize=None, adjust_bottom=0.2, adjust_left=0.2) @@ -248,6 +247,12 @@ guan.plot_3d_surface(x_array, y_array, matrix, xlabel='x', ylabel='y', zlabel='z guan.plot_contour(x_array, y_array, matrix, xlabel='x', ylabel='y', title='', fontsize=20, labelsize=15, show=1, save=0, filename='a', format='jpg', dpi=300) +guan.combine_two_images(image_path_array, figsize=(16,8), show=0, save=1, save_name='a', save_format='jpg', dpi=300) + +guan.combine_three_images(image_path_array, figsize=(16,5), show=0, save=1, save_name='a', save_format='jpg', dpi=300) + +guan.combine_four_images(image_path_array, figsize=(16,16), show=0, save=1, save_name='a', save_format='jpg', dpi=300) + # data processing diff --git a/PyPI/setup.cfg b/PyPI/setup.cfg index 9a85b7b..6584f72 100644 --- a/PyPI/setup.cfg +++ b/PyPI/setup.cfg @@ -1,7 +1,7 @@ [metadata] # replace with your username: name = guan -version = 0.0.78 +version = 0.0.79 author = guanjihuan author_email = guanjihuan@163.com description = An open source python package diff --git a/PyPI/src/guan/__init__.py b/PyPI/src/guan/__init__.py index b5d2883..bbda342 100644 --- a/PyPI/src/guan/__init__.py +++ b/PyPI/src/guan/__init__.py @@ -1592,6 +1592,86 @@ def plot_contour(x_array, y_array, matrix, xlabel='x', ylabel='y', title='', fon plt.show() plt.close('all') +def combine_two_images(image_path_array, figsize=(16,8), show=0, save=1, save_name='a', save_format='jpg', dpi=300): + num = np.array(image_path_array).shape[0] + if num != 2: + print('Error: The number of images should be two!') + else: + import matplotlib.pyplot as plt + import matplotlib.image as mpimg + fig = plt.figure(figsize=figsize) + plt.subplots_adjust(left=0, right=1, bottom=0, top=1, wspace=0, hspace=0) + ax1 = fig.add_subplot(121) + ax2 = fig.add_subplot(122) + image_1 = mpimg.imread(image_path_array[0]) + image_2 = mpimg.imread(image_path_array[1]) + ax1.imshow(image_1) + ax2.imshow(image_2) + ax1.axis('off') + ax2.axis('off') + if show == 1: + plt.show() + if save == 1: + plt.savefig(save_name+'.'+save_format, dpi=dpi) + plt.close('all') + +def combine_three_images(image_path_array, figsize=(16,5), show=0, save=1, save_name='a', save_format='jpg', dpi=300): + num = np.array(image_path_array).shape[0] + if num != 3: + print('Error: The number of images should be three!') + else: + import matplotlib.pyplot as plt + import matplotlib.image as mpimg + fig = plt.figure(figsize=figsize) + plt.subplots_adjust(left=0, right=1, bottom=0, top=1, wspace=0, hspace=0) + ax1 = fig.add_subplot(131) + ax2 = fig.add_subplot(132) + ax3 = fig.add_subplot(133) + image_1 = mpimg.imread(image_path_array[0]) + image_2 = mpimg.imread(image_path_array[1]) + image_3 = mpimg.imread(image_path_array[2]) + ax1.imshow(image_1) + ax2.imshow(image_2) + ax3.imshow(image_3) + ax1.axis('off') + ax2.axis('off') + ax3.axis('off') + if show == 1: + plt.show() + if save == 1: + plt.savefig(save_name+'.'+save_format, dpi=dpi) + plt.close('all') + +def combine_four_images(image_path_array, figsize=(16,16), show=0, save=1, save_name='a', save_format='jpg', dpi=300): + num = np.array(image_path_array).shape[0] + if num != 4: + print('Error: The number of images should be four!') + else: + import matplotlib.pyplot as plt + import matplotlib.image as mpimg + fig = plt.figure(figsize=figsize) + plt.subplots_adjust(left=0, right=1, bottom=0, top=1, wspace=0, hspace=0) + ax1 = fig.add_subplot(221) + ax2 = fig.add_subplot(222) + ax3 = fig.add_subplot(223) + ax4 = fig.add_subplot(224) + image_1 = mpimg.imread(image_path_array[0]) + image_2 = mpimg.imread(image_path_array[1]) + image_3 = mpimg.imread(image_path_array[2]) + image_4 = mpimg.imread(image_path_array[3]) + ax1.imshow(image_1) + ax2.imshow(image_2) + ax3.imshow(image_3) + ax4.imshow(image_4) + ax1.axis('off') + ax2.axis('off') + ax3.axis('off') + ax4.axis('off') + if show == 1: + plt.show() + if save == 1: + plt.savefig(save_name+'.'+save_format, dpi=dpi) + plt.close('all')