我正在为以后的动画绘制和保存数千个文件,如下所示:
import matplotlib.pyplot as plt
for result in results:
plt.figure()
plt.plot(result) # this changes
plt.xlabel('xlabel') # this doesn't change
plt.ylabel('ylabel') # this doesn't change
plt.title('title') # this changes
plt.ylim([0,1]) # this doesn't change
plt.grid(True) # this doesn't change
plt.savefig(location, bbox_inches=0) # this changes
当我运行这个有很多结果时,它会在保存数千个图后崩溃。我想我想做的是像这个答案一样重用我的轴:https ://stackoverflow.com/a/11688881/354979但我不明白如何。我该如何优化它?