[英]Animated 2D Histogram
我不確定我想要的是否可行。 我還沒有找到解決方案。 我有數據,可以用 Matplotlib 的 hist2d 顯示。 有沒有辦法從列表列表中渲染許多(!)這些直方圖的視頻/動畫?
非常感謝!
這是一個簡單的例子,說明如何做到這一點。 如果您不希望之前的圖在每一幀之后消失,您應該刪除ax.clear()
調用。
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
fig, ax = plt.subplots()
data = [[1, 2, 3], [1, 2, 2, 3], [1, 2, 2, 2, 3], [1, 2, 2, 2, 3, 3]]
def plot(frame):
ax.clear()
ax.hist(frame)
# blit=True may be helpful if you're using plt.plot() directly.
ani = FuncAnimation(fig, plot, frames=data, blit=False)
plt.show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.