1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Pythonでモードアニメーション

Posted at

Pythonによる簡易的なモードアニメーションの例

Sin波形の振幅が変化するアニメーションプロット

mode_anim.py
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation

# モード形状データ(例)
x = np.linspace(0, 10, 100)
mode_shape = np.sin(x)

# アニメーション用データ生成
def update(frame):
    line.set_ydata(mode_shape * np.sin(2 * np.pi * frame / 100))
    return line,

# プロット設定
fig, ax = plt.subplots()
line, = ax.plot(x, mode_shape)
ax.set_ylim(-1.5, 1.5)

# アニメーション作成
ani = FuncAnimation(fig, update, frames=100, interval=50)

# GIFとして保存
ani.save("animation.gif", writer='pillow', fps=10)

# アニメーションの表示
plt.show()

animation.gif

1
0
0

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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?