- 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
What is the currently correct way to dynamically update plots in Jupyter/iPython?
We can first activate the figure using plt.ion() method. Then, we can update the plot with different sets of values.
Steps
Create fig and ax variables using subplots method, where default nrows and ncols are 1.
Draw a line, using plot() method.
Set the color of line, i.e., orange.
Activate the interaction, using plt.ion() method.
To make the plots interactive, change the line coordinates.
Example
In [1]: %matplotlib auto Using matplotlib backend: GTK3Agg In [2]: import matplotlib.pyplot as plt # Diagram will get popped up. Let’s update the diagram. In [3]: fig, ax = plt.subplots() # Drawing a line In [4]: ax.plot(range(5)) In [5]: plt.ion() # updating figures with new lines. In [6]: ax.plot([1, 3, 4], [4, 6, 1])
Output
- Related Articles
- Displaying rotatable 3D plots in IPython or Jupyter Notebook
- How to dynamically update a plot in a loop in Ipython notebook?
- Best way to display Seaborn/Matplotlib plots with a dark iPython Notebook profile
- How to display print statements interlaced with Matplotlib plots inline in iPython?
- What is the correct way to define global variables in JavaScript?
- What is the correct way to define class variables in Python?
- How do I get interactive plots again in Spyder/Ipython/matplotlib?
- What is the correct way to check if String is empty in Java?
- What is the fastest way to update the whole document (all fields) in MongoDB?
- How to dynamically update a listView in Android?
- What is the correct way of using , , or in HTML?
- MongoDB query to update field and modify the data currently in column
- How to dynamically update a ListView on Android
- What is the correct way to use printf to print a size_t in C/C++?
- What is the correct way to replace matplotlib tick labels with computed values?

Advertisements