1 回答
TA贡献1836条经验 获得超4个赞
我对此没有太多经验,但我能够显示我事先调用的图像plt.imshow()。demo.gif由于文件大小限制,无法上传。抱歉,示例中使用的图片效果不佳。对不起。
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib.animation import PillowWriter
import time
import matplotlib.image as mpimg
rng = np.random.default_rng()
fig = plt.figure(figsize=[10, 9])
img = mpimg.imread('lena_thumbnail_center_square.jpg')
ims = []
for i in range(200):
df = pd.DataFrame(rng.integers(0, 100, size=(100, 2)), columns=list('xy'))
x = df["x"]
y = df["y"]
im = plt.plot(x, y, "b.")
ims.append(im)
# print(i)
ani = animation.ArtistAnimation(fig, ims, interval=500, blit=True,
repeat_delay=1000)
plt.imshow(img)
writer = PillowWriter(fps=2)
ani.save("demo2.gif", writer=writer)
添加回答
举报