19
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Jupyter notebookにMatplotlibでリアルタイムにチャートを書く

Posted at

Jupyter notebook上でリアルタイムに変化するチャートを書くのに苦労したのでコードを記載しておきます。

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()
19
21
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?