title: How to generate result as the figure title along with filename connected with the plotted image?
body: <p>I need help please, to bring the test results and the file name together as the title over the image that is evaluated. I can generate the test results as a list (see image), I can add the test results over the image. I can add the file name over the top of the image. But, I cannot do both. Not sure what I am doing wrong. Thank you.
  <a href="https://i.stack.imgur.com/NUeGy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NUeGy.png" alt="enter image description here" /></a></p>
  <pre><code>path = '/Users/minny/Desktop/A/png/file2/'
  ref_images = glob.iglob(path + &quot;*.png&quot;)  
  all_ref_images = []  
  
  
  
  for ref_path in ref_images:  
      ref_head, tail = os.path.splitext(ref_path) 
      image1 = Image.open(ref_path) 
      imgA= print(calculate_brightness(image1))
      #all_ref_images.append([imgA, ref_head])    
      ref_image = plt.imshow(image1)
      fig = plt.figure()
      
      
      plt.title(os.path.basename(ref_head)), plt.title(calculate_brightness(image1))
      
      
      #plt.axis(&quot;off&quot;)
  </code></pre>
  <pre><code>def calculate_brightness(image):
  greyscale_image = image.convert('L')
  histogram = greyscale_image.histogram()
  pixels = sum(histogram)
  brightness = scale = len(histogram)
  
  for index in range(0, scale):
      ratio = histogram[index] / pixels
      brightness += ratio * (-scale + index)
  
  return 1 if brightness == 255 else brightness / scale
  
  %%capture
  
   #gives a standard size image to view inline with the text
   def display_img(img, cmap=None):
       fig = plt.figure(figsize=(3,3))
       ax = fig.add_subplot(111)
       ax.imshow(img, cmap)
   
  
   path = '/Users/minny/Desktop/A/png/file2/'
   ref_images = glob.iglob(path + &quot;*.png&quot;)  
   all_ref_images = []  
  
  for ref_path in ref_images:  
      ref_head, tail = os.path.splitext(ref_path) 
      image1 = Image.open(ref_path) 
      imgA= print(calculate_brightness(image1))
      all_ref_images.append([imgB, ref_head])               
      fig = plt.figure()      
      ref_image = plt.imshow(image1)
      print(os.path.basename(ref_head))        
      #plt.axis(&quot;off&quot;)
  
      ref_image = plt.imshow(image1)
      image_basename = os.path.basename(ref_head)
      title = '\n'.join([image_basename, str(calculate_brightness(image1))])
      plt.title(title, loc='left')
  
      dir_name = '/Users/minny/Desktop/A/png/results/'
      plt.savefig('{dir_name}/{filename}'.format(dir_name=dir_name, filename=image_basename))
  </code></pre>