I try to overwrite a figure with matplotlib together with os.remove() using below code. Why is the creation date not updated? (I am using Anaconda Prompt)
the code is source from here: Matplotlib Savefig will NOT overwrite old files
some suggest using os.remove(os.path.join(path, del_file))
as here:Python os.remove fails to remove But that didn't work for me.
Is there a way to code up something to update the creation date?
import os
import matplotlib.pyplot as plt
#make figure
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
#save
strFile = "./figs/my_plot.jpg"
if os.path.isfile(strFile):
os.remove(strFile) # Opt.: os.system("rm "+strFile)
plt.savefig(strFile)
Edits: I am using windows system.