matplotlib - IOError "Too many open files" while using savefig() in a loop -
i have little issue matplotlib. while trying save figures in loop hundred times savefig()
, ends following error:
ioerror: [errno 24] many open files: 'test_421.png'
i have checked close every figure
after saving it, doesn't seem efficient.
here code sample illustrate how error:
def displayfig(input, display, savepath): fig = plt.figure(figsize=(22, 5)) # add subplots, axis , colorbars... if display: plt.show() else: plt.savefig(savepath, dpi = 100) plt.close(fig) i, inp in enumerate(inparray): savepath = 'test_%d.png' % displayfig(inp, false, savepath)
why error raised? multi-threading issue or memory leak?
try upgrading version of matplotlib. believe matplotlib v1.2.0 addressed (by pr https://github.com/matplotlib/matplotlib/issues/1466/).
Comments
Post a Comment