title: Python: Keep savefig from overwriting old plots
body: <p>I simply use</p>
  
  <pre><code>plt.savefig(filename+'.png', format='png')
  </code></pre>
  
  <p>to save my plots. But I want to keep my old versions of <code>filename.png</code> when I create a new one (using different colour codes, etc.) without always having to come up with a new filename.</p>
  
  <p>Since I don't do that in one run, <a href="https://stackoverflow.com/questions/13555069/saving-multiple-plots"><em>this</em></a> doesn't help me. I found <a href="https://stackoverflow.com/questions/1348026/how-do-i-create-a-file-in-python-without-overwriting-an-existing-file"><em>this</em></a> on how to keep Python from overwriting files, but that's for <code>os</code>. Is there a way to do this with <code>savefig</code>?</p>
  
  <p>In the end I want Python to check whether <code>filename.png</code> exists and only if so, save the new figure as <code>filename1.png</code>, <code>filename2.png</code>, etc.</p>