plt.close() added in the loop for savefig