How to dynamically update a plot in a loop in Ipython notebook (within one cell)

后端 未结 6 1479
梦如初夏
梦如初夏 2020-11-28 02:19

Environment: Python 2.7, matplotlib 1.3, IPython notebook 1.1, linux, chrome. The code is in one single input cell, using --pylab=inline

I want to use I

6条回答
  •  独厮守ぢ
    2020-11-28 02:42

    use IPython.display module:

    %matplotlib inline
    import time
    import pylab as pl
    from IPython import display
    for i in range(10):
        pl.plot(pl.randn(100))
        display.clear_output(wait=True)
        display.display(pl.gcf())
        time.sleep(1.0)
    

提交回复
热议问题