I simply use
plt.savefig(filename+'.png', format='png')
to save my plots. But I want to keep my old versions of filename.png
when I create a new one (using different colour codes, etc.) without always having to come up with a new filename.
Since I don't do that in one run, this doesn't help me. I found this on how to keep Python from overwriting files, but that's for os
. Is there a way to do this with savefig
?
In the end I want Python to check whether filename.png
exists and only if so, save the new figure as filename1.png
, filename2.png
, etc.