Skip to content

Document a trick for dynamic plotting in Jupyter/iPython #1415

@wangkuiyi

Description

@wangkuiyi

We tried the following code snippet. It works with try.jupyter.org:

%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())
    pl.gcf().clear()
    time.sleep(1.0)

where pl.gcf().clear() clears existing plots.

Documents for users' review: https://ipython.org/ipython-doc/3/api/generated/IPython.display.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions