title: Looping over data and creating individual figures
body: <p>I'm looping over a list of names of different molecules and trying to generate individual figs for each of them. But for each successive molecule the new figures have all the previous data on as well. I've printed the data after I've gathered it and for each loop it's showing the correct amount. Here's my full code</p>
  
  <pre><code>import matplotlib
  import matplotlib.pyplot as plt
  import numpy as np
  
  mols = ["P_Z1", "P_Z2", "TT_Z1", "TT_Z2", "TP_Z1", "TP_Z2"]
  
  
  for mol in mols:
      en = []
      den = []
      with open (mol+"clustered.txt") as f:
          for line in f:
              e = line.strip().split()[1]
              en.append(e)
      with open (mol+"densities.txt") as g:
          for line in g:
              d = line.strip()
              den.append(d)
      data = zip(en,den)
      print data
      for energy, density in data:
          plt.xlabel("Density g/cubic cm")
          plt.ylabel("Energy kJ/mol")
          ax = plt.gca()
          ax.spines["right"].set_color('none')
          ax.xaxis.set_ticks_position('top')
          ax.yaxis.set_ticks_position('left')
          ax.spines["bottom"].set_color('none')
          ax.xaxis.set_label_position('top')
          ax.spines['left'].set_color('black')
          ax.spines['top'].set_color('black')
          ax.xaxis.label.set_color('black')
          ax.yaxis.label.set_color('black')
          ax.tick_params(colors='black')
          plt.plot(density, energy, "ro")
          plt.savefig(mol+".png", bbox_inches="tight", dpi=200, transparent=True)
  </code></pre>
  
  <p>Any help would be greatly appreciated!</p>