Image titles not displaying in loop


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 [image, image_title].

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
    for image in img_list:
        image_file_name = image[1]
        plt.subplot(num_rows, cols, i)        
        plt.title = image_file_name
        plt.imshow(image[0], cmap=cmap)        
        i += 1 
Asked By: dvd940



If you reassign plt.title, the title() function is overwritten by a string.

Instead you need to call the plt.title() function.

Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.