So I have a function generategraph(file) which correctly creates a bar graph based on the data in the parameter and then saves it. Here is the part that saves it.
plt.show()
savefile = file.split('.txt')[0] + '.png'
plt.savefig(savefile)
then in main, I will go through a set of files and call generategraph on each one.
for fil in files:
generategraph(fil)
plt.show() gives me the correct graphs (different graphs each time), but when I go to the saved figures they are all of the same graph (so len(files) number of saved figures but each one is the graph of the first file if that makes sense). I am just confused because plt.show() is doing what I want plt.savefig to do.
return
the figure fromgenerategraph
and usefig.savefig(path)
:for fil in files: fig = generategraph(fil); fig.savefig(fil.split('.txt')[0])
– Novak