Write charts in real time with Matplotlib on Jupyter notebook

I had a hard time writing a chart that changes in real time on Jupyter notebook, so I will write the code here.

import matplotlib
%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt

plt.ion()

from random import randint
import time

from ipywidgets import FloatProgress
from IPython.display import display, clear_output

siz = 10
dat = np.zeros((siz, siz))

fig = plt.figure()
axe = fig.add_subplot(111)

num = 1000

for i in range(num):
    clear_output(wait = True)
    
    data = np.random.rand(10)
    axe.plot(data)
    
    fig.set_size_inches(18.5, 10.5)
    display(fig)
#     time.sleep(.2)
    axe.cla()

Recommended Posts

Write charts in real time with Matplotlib on Jupyter notebook
High charts on Jupyter notebook
Formatting with autopep8 on Jupyter notebook
Resolve garbled Japanese characters in matplotlib of Jupyter Notebook on Docker
Try SVM with scikit-learn on Jupyter Notebook
Write SVG graphs with matplotlib on heroku
[Jupyter Notebook memo] Display kanji with matplotlib
Install matplotlib and display graph on Jupyter Notebook
Enable Jupyter Notebook with conda on remote server
Graph drawing with jupyter (ipython notebook) + matplotlib + vagrant
Try converting videos in real time with OpenCV
Monitor the training model with TensorBord on Jupyter Notebook
Get standard output in real time with Python subprocess
Drawing a tree structure with D3.js in Jupyter Notebook
Read the csv file with jupyter notebook and write the graph on top of it
Try converting webcam / camcorder videos in real time with OpenCV
Using Graphviz with Jupyter Notebook
Machine learning with Jupyter Notebook in OCI Always Free environment (2019/12/17)
Display HTML in Jupyter notebook
Use pip with Jupyter Notebook
Multiprocessing error in Jupyter Notebook
Reflect the virtual environment created with Miniconda in Jupyter notebook
Install Jupiter Notebook on Windows with pip in proxy environment
Use Cython with Jupyter Notebook
Play with Jupyter Notebook (IPython Notebook)
Create SVG graph with matplotlib on heroku (displayed in Japanese)
Get YouTube Live chat field in real time with API
Unable to display tensorboard in jupyter notebook on docker (solved)
Try clustering with a mixed Gaussian model on a Jupyter Notebook
Run Jupyter Notebook on windows
Day 65 I installed matplotlib to draw graphs on my Jupyter notebook.
I tried to describe the traffic in real time with WebSocket
Git management of Jupyter notebook (ipynb) differences in easy-to-read with JupyterLab
Draw optical flow in real time with OpenCV (Shi-Tomasi method, Lucas-Kanade method)
How to write offline real time Solve F01 problems with Python
Allow external connections with jupyter notebook
Visualize decision trees with jupyter notebook
Make a sound with Jupyter notebook
Draw Japanese with matplotlib on Ubuntu
Generate Jupyter notebook ".ipynb" in Python
Run azure ML on jupyter notebook
Use markdown with jupyter notebook (with shortcut)
Add more kernels with Jupyter Notebook
View graphs inline in Jupyter Notebook
Heatmap with Dendrogram in Python + matplotlib
Convenient analysis with Pandas + Jupyter notebook
Try running Jupyter Notebook on Mac
Write a stacked histogram with matplotlib
[Small story] How to save matplotlib graphs in a batch with Jupyter
I wanted to use jupyter notebook with docker in pip environment (opticspy)
Use Jupyter Notebook with Visual Studio Code on Windows 10 + Python + Poetry + pyenv-win
How to write offline real time I tried to solve E11 with python
Settings when reading S3 files with pandas from Jupyter Notebook on AWS
Plot CSV of time series data with unixtime value in Python (matplotlib)
How to write offline real time I tried to solve E12 with python
Write documentation in Sphinx with Python Livereload
Displaying candlestick charts in Python (matplotlib edition)
Memory leak in Python Jupyter Lab (Notebook)?
Use apache Spark with jupyter notebook (IPython notebook)
Jupyter Notebook does not show matplotlib graphs
I want to blog with Jupyter Notebook