Matplotlib:重新打开封闭的数字?

时间:2012-03-08 16:20:25

标签: matplotlib

是否有可能在matplotlib中重新打开一个封闭的数字(即用户X'd)?以下代码显示了天真的方法:

In [14]: fig = figure(10)

In [15]: close(fig)

In [16]: fig.show()

Exception in Tkinter callback
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/Tkinter.py", line 1410, in __call__
    return self.func(*args)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/Tkinter.py", line 495, in callit
    func(*args)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/backend_tkagg.py", line 253, in idle_draw
    self.draw()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/backend_tkagg.py", line 239, in draw
    tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/tkagg.py", line 19, in blit
    tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox_array))
TclError: this isn't a Tk application

我正在尝试创建一个带有小部件的图形,因此可以使用解决方法(只需创建一个新图形),但我想知道figure实例在关闭后是否完全没用。

1 个答案:

答案 0 :(得分:1)

是的,关闭数字会完全删除它。