0
import matplotlib.pyplot as plt
plt.ion()
fig = plt.figure()
axe = fig.add_subplot(111)
axe.plot(x,y,'b-')
axe.plot(z,h,'r-')

Now, I can see 2 lines (blue and red) plotted on figure. But I accidentally close that figure window.

when I issue command fig.show(), or fig.draw(), the figure will never show up again. How can I bring up my original figure without executing above commands again? Thanks in advance.

Yan Tian
  • 377
  • 3
  • 11

1 Answers1

0

I ran your code but I'm not getting the output you described. "2 lines (blue and red) plotted on figure"

Closing the figure via gui destroys the gui toolkit, however, the figure object still exists, you can save it with fig.savefig(). I think the best approach would be re-creating the figure.

Hopefully this helps: Matplotlib: how to show a figure that has been closed.

Samuel L.
  • 74
  • 9