How to dynamically update a plot in a loop in Ipython notebook?

We can iterate a plot using display.clear_output(wait=True), display.display(pl.gcf()) and time.sleep() methods in a loop to get the exact output.


  • Plot a sample (or samples) from the "standard normal" distribution using pylab.randn().

  • Clear the output of the current cell receiving output, wait=False(default value), wait to clear the output until new output is available to replace it.

  • Display a Python object in all frontends. By default, all representations will be computed and sent to the frontends. Frontends can decide which representation is used and how, using the display() method. pl.gcf helps to get the current figure.

  • To sleep for a while, use time.sleep() method.


import time
import pylab as pl
from IPython import display
for i in range(2):