Matplotlib pyplot show() doesn't work once closed

前端 未结 4 853
迷失自我
迷失自我 2020-12-31 20:06

I have a loop like this

#!/usr/bin/env python
import matplotlib.pyplot as p

for i in xrange(N):
    # Create my_image here

    # Display this image
    p.fi         


        
4条回答
  •  没有蜡笔的小新
    2020-12-31 20:54

    After tinkering around with unutbu's example, I found a behavior that I could normally and debug with PyDev where I could progressively see the plots.

    import time, threading
    import numpy
    from matplotlib.pyplot import *
    
    x = numpy.linspace(0, 10)
    y = x**2
    
    def main():
        plot(x, x)
        draw()
        time.sleep(2)
        plot(x, y)
        draw()
    
    thread = threading.Thread()
    thread.run = main
    
    manager = get_current_fig_manager()
    manager.window.after(100, thread.start)
    figure(1)
    show()
    

提交回复
热议问题