小编Mik*_*TeX的帖子

如何等到matplotlib动画结束?

请考虑直接从Matplotlib文档中获取的以下代码:

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import time # optional for testing only
import cv2 # optional for testing only

fig = plt.figure()   

def f(x, y):
    return np.sin(x) + np.cos(y)

x = np.linspace(0, 2 * np.pi, 120)
y = np.linspace(0, 2 * np.pi, 100).reshape(-1, 1)

im = plt.imshow(f(x, y), animated=True)    

def updatefig(*args):
    global x, y
    x += np.pi / 15.
    y += np.pi / 20.
    im.set_array(f(x, y))
    return im,

ani = animation.FuncAnimation(fig, updatefig, …
Run Code Online (Sandbox Code Playgroud)

python animation multithreading matplotlib

6
推荐指数
1
解决办法
4194
查看次数

标签 统计

animation ×1

matplotlib ×1

multithreading ×1

python ×1