1

i have a problem where i cannot figure out how to place images next to each other in irregular grid and remove all the grid liens, axes and values.

import os
import matplotlib.pyplot as plt

# directory and single image size in the grid
images_dir = '../Desktop/test'  # source directory
result_grid_filename = '../Desktop/grid2.jpg' # destination directory and file name
result_figsize_resolution = 100 # single image size

images_list = os.listdir(images_dir)
images_count = len(images_list)
print('Images count: ', images_count)

Nrows = 3
Ncolumes = 6

# Create plt plot:
fig, ax = plt.subplots(Nrows, Ncolumes, figsize=(result_figsize_resolution, result_figsize_resolution))
current_file_number = 0

ax = []

for image_filename in images_list:

    img = plt.imread(images_dir + '/' + images_list[current_file_number])

    # create subplot and append to ax
    ax.append(fig.add_subplot(Nrows, Ncolumes, current_file_number + 1))

    plt.imshow(img)
    plt.axis('off')
    current_file_number += 1

plt.subplots_adjust(wspace=0, hspace=0, left=0.0, right=1.0, bottom=0.0, top=1.0)
plt.savefig(result_grid_filename, bbox_inches="tight")

0 Answers0