コンテンツへスキップ

Pythonプログラムによるプロットアニメーション【プログラミング】

湯どうふと申します。
本チャンネルでは、化学に関する動画を配信しています。

音声:湯どうふ

キーワード:
アニメーション、gif、matplotlib、プロット、動画、PillowWriter

Pythonプログラムによるwordファイルの入出力とGoogle翻訳自動化作業

PythonプログラムによるExcelファイルの入出力

Pythonプログラムで3次元グラフを作成し保存する手順

Pythonプログラムでグラフを作成し保存する手順

Pythonによるwebスクレイピングの初歩

理論系研究室のためのトラブル予防法:UPSの基礎知識

動画で紹介したプログラム例
anime.py

import numpy as np
import math
import matplotlib.pyplot as plt
from matplotlib import animation
from matplotlib.animation import PillowWriter

def _update(frame, x, y):
plt.cla()

x. append(frame)
y.append(math.sin(frame)*math.exp(-0.01*frame))

plt.xlim(0, 50)
plt.ylim(-1, 1)
plt.plot(x, y)

fig = plt.figure(figsize=(10, 6))

x, y = [], []

params =
‘fig’: fig,
‘func’: _update,
‘fargs’: (x, y),
‘interval’: 10,
‘frames’: np.arange(0, 50, 0.1),
‘repeat’: False, # not repeat

ani = animation.FuncAnimation(**params)
ani.save(‘anim.gif’, writer=”pillow”)

Facebooktwittermail

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA