我在matplotlib做了一个动画.您可以在下面找到我的代码的简化:
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
begin = 62
eind = 227
verschil = eind - begin
fig = plt.figure()
def f(x, y):
return np.sin(x) + (0*y)
x = np.linspace(0, 2 * np.pi, 501)
y = np.linspace(0, 2 * np.pi, 501).reshape(-1, 1)
afbeeldinglijst = []
for i in range(verschil):
x = x + 1
titel = begin + 1
afbeelding = plt.imshow(f(x, y))
afbeeldinglijst.append([afbeelding])
plt.colorbar()
plt.title(titel)
plt.clim(-0.8,0.8)
A …Run Code Online (Sandbox Code Playgroud)