title: Colobars multiplying each loop
body: <pre><code>fig, (ax0, ax1) = plt.subplots(ncols=2, figsize=(9.5, 4), facecolor='w')
  
  for i in range(100):
      h = ax0.hist2d(globals()['grid1_pulse'+str(i)+'_df']['#Row'], globals()['grid1_pulse'+str(i)+'_df']['#Col'], weights=globals()['grid1_pulse'+str(i)+'_df']['#ToA'], bins = GridX1max-GridX1min, range = [(GridX1min, GridX1max), (GridY1min, GridY1max)], norm=mpl.colors.LogNorm())
      fig.colorbar(h[3], ax = ax0)
  
      h = ax1.hist2d(globals()['grid1_pulse'+str(i)+'_df']['#Row'], globals()['grid1_pulse'+str(i)+'_df']['#Col'], weights=globals()['grid1_pulse'+str(i)+'_df']['#ToT[arb]'], bins = GridX1max-GridX1min, range = [(GridX1min, GridX1max), (GridY1min, GridY1max)], norm=mpl.colors.LogNorm())
      fig.colorbar(h[3], ax = ax1)
  
      fig.tight_layout()
  
      fig.savefig('gridtoatot_frame'+str(i)+'.png', bbox_inches='tight')
      plt.close(&quot;all&quot;)
  plt.show()
  </code></pre>
  <p>I am getting this and I can't seem to work out a solution. plt.close(&quot;all) and plt.clf() seem to have no effect:</p>
  <p><a href="https://i.stack.imgur.com/61W2O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/61W2O.png" alt="enter image description here" /></a></p>
  <p>Each plot should look like this:
  <a href="https://i.stack.imgur.com/y8PMb.png" rel="nofollow noreferrer">enter image description here</a></p>