I have data analysis module that contains functions which call on Matplotlib pyplot API multiple times to generate up to 30 figures in each run. These figures get immediatel
Especially when you are running multiple processes or threads, it is much better to define your figure variable and work with it directly:
from matplotlib import pyplot as plt f = plt.figure() f.clear() plt.close(f)
In any case, you must combine the use of plt.clear() and plt.close()