I wish to display images in a loop with the image name as a title. Each image displays in the loop but the title does not.
In the function below, the
img_list contains lists with the following
def display_images(img_list, cmap='gray', cols = 2, fig_size = (10, 10) ): """ Display images in img_list """ i = 1 # for subplot num_images = len(img_list) num_rows = num_images / cols plt.figure(figsize=fig_size) for image in img_list: image_file_name = image plt.subplot(num_rows, cols, i) plt.title = image_file_name plt.imshow(image, cmap=cmap) i += 1 plt.show()
If you reassign
title() function is overwritten by a string.
Instead you need to call the