title: imshow subplot placement inside matplotlib figure
body: <p>I have a Python script that draws a matrix of images, each image is read from disk and is 100x100 pixels. Current result is:</p>
  <p><a href="https://i.stack.imgur.com/izpgF.png" rel="nofollow noreferrer">matrix of images</a></p>
  <p>I don't know why Python adds vertical spacing between each row. I tried setting several parameters for <code>plt.subplots</code>. Rendering code is below:</p>
  <pre><code>fig, axs = plt.subplots(
      gridRows, gridCols, sharex=True, sharey=False, constrained_layout={'w_pad': 0, 'h_pad': 0, 'wspace': 0, 'hspace': 0}, figsize=(9,9)
  )
  k = 0
  
  for i in range(len(axs)):
      for j in range(len(axs[i])):
          if (k &lt; paramsCount and dataset.iat[k,2]):
              img = mpimg.imread(&lt;some_folder_path&gt;)
          else:
              img = mpimg.imread(&lt;some_folder_path&gt;)
              
          ax = axs[i, j]    
          ax.imshow(img)
          ax.axis('off')
          if (i == 0): ax.set_title(dataset.iat[k,1])
          if (j == 0): ax.text(-0.2, 0.5, dataset.iat[k,0], transform=ax.transAxes, verticalalignment='center', rotation='vertical', size=12)
          
          axi = ax.axis()
          rec = plt.Rectangle((axi[0], axi[2]), axi[1] - axi[0], axi[3] - axi[2], fill=False, lw=1, linestyle=&quot;dotted&quot;)
          rec = ax.add_patch(rec)
          rec.set_clip_on(False)
  
          k = k + 1
  
  plt.show()
  </code></pre>
  <p>Desired result is like:</p>
  <p><a href="https://i.stack.imgur.com/JrOGE.png" rel="nofollow noreferrer">desired result</a></p>
  <p>Does anyone have ideas?</p>