- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
Steps
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.
Example
import time import pylab as pl from IPython import display for i in range(2): pl.plot(pl.randn(100)) display.clear_output(wait=True) display.display(pl.gcf()) time.sleep(1.0)
Output
Figure(640x480) Figure(640x480)
- Related Articles
- Plot width settings in ipython notebook\n\n
- How to hide in IPython notebook?
- What is the currently correct way to dynamically update plots in Jupyter/iPython?
- How to dynamically update a listView in Android?
- Automatically run %matplotlib inline in IPython Notebook
- Matplotlib animation not working in IPython Notebook?
- How to set the matplotlib figure default size in ipython notebook?
- How to display a Dataframe next to a Plot in Jupyter Notebook?
- How to dynamically update a ListView on Android
- Displaying rotatable 3D plots in IPython or Jupyter Notebook
- How do I show the same Matplotlib figure several times in a single IPython notebook?
- How to dynamically add/remove/update labels in a Tkinter window?
- How to dynamically update a ListView on Android Kotlin?
- Best way to display Seaborn/Matplotlib plots with a dark iPython Notebook profile
- Dynamically updating a bar plot in Matplotlib

Advertisements