I know there are "current figure" and "current axes" in matplotlib but if I run the following code line by line in a spyder ipython console, the "plt.get_fignums()" always returns an empty list. If the "current figure" and "current axes" are cleared after each run, why do the plt.gcf() and plt.gca() still return something? Does that mean matplotlib always keeps a blank figure and axes when initialized? Does it has anything to do with the "interactive mode" of matplotlib?
import matplotlib.pyplot as plt
plt.figure()
print(plt.get_fignums())
print(plt.gcf(),plt.gca())
Update:I make the code simpler to demo the problem
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] Type "copyright", "credits" or "license" for more information.
IPython 7.6.1 -- An enhanced Interactive Python.
In [1]: runfile('xxx.py', wdir='xxx')
[1]
Figure(432x288) AxesSubplot(0.125,0.125;0.775x0.755)
In [2]: print(plt.get_fignums())
...: print(plt.gcf(),plt.gca())
[]
Figure(432x288) AxesSubplot(0.125,0.125;0.775x0.755)
In [6]: plt.figure()
...: print(plt.get_fignums())
[1]
<Figure size 432x288 with 0 Axes>
In [7]: print(plt.get_fignums())
[]