Interactive matplotlib through Eclipse PyDev

前端 未结 4 1710
难免孤独
难免孤独 2020-12-17 02:15

This is a follow up to this interactive matplolib through eclipse thread which is about 2 years old, I was wondering if there has been any progress in the meantime.

4条回答
  •  情话喂你
    2020-12-17 02:40

    I achieve similar behave in Eclipse PyDev by executing plotting function in another thread:

    import threading
    from pylab import *
    import matplotlib.animation as animation
    import time
    
    x = array(range(0,1000))/100
    y = sin(x)
    
    def updateData(self):
        ax.set_data(x,y)
    
    def MyThread():
        global ax
        fig, axarr = subplots(1)
        ax, = axarr.plot(x,y)
        simulation = animation.FuncAnimation(fig, updateData)
        show()
    
    
    t = threading.Thread(target=MyThread)
    t.start()
    
    # console stay active, user can interactively control figure
    time.sleep(1)
    y = sin(2*x)
    time.sleep(2)
    ax.get_axes().grid()
    ax.get_axes().set_xlabel("time")
    

    Tested with toolchain Eclipse 4.3, PyDev 2.7.1, Python 3.2, IPython 0.13

提交回复
热议问题