I would like to use matplotlib.pyplot to display many images in my jupyter notebook. However, when I try to display more than 20, a runtime warning appears, since images are kept in memory if not closed:
RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (
matplotlib.pyplot.figure) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam figure.max_open_warning).
I am using %matplotlib inline
If I close the plot plt.close(), the plots are not displayed. How can I can close the plot and still look at the plot in jupyter, I need to look at many images simultanously: I am using a loop where crop and value are two images.
plt.figure()
f, axarr = plt.subplots(1,2)
plt.title('Image: ' + str(key))
plt.gray()
axarr[0].imshow(crop)
axarr[1].imshow(value)
plt.close()