【发布时间】:2021-04-03 18:30:52
【问题描述】:
我正在尝试使用 matplotlib 不使用 FuncAnimation 制作 动画,因为它会导致 HTML (ffmpeg) 出现问题。我现在正在尝试使用更常用于实况剧情的plt.ion()。
我制作动画没有问题,但曲线并没有真正移动,大部分时间是边界在移动。
我尝试了通常的界限,比如 set plt.xlim(#boundaries) 和 for the y... 但它没有用。关于如何解决问题的任何线索?
这是我所做的(这只是示例代码,因为我想做的动画是量子波函数,而那个代码已经有点乱了)
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
a = int(input("render level = "))
tmax = float(input("tmax = "))
x = np.linspace(0, 2*np.pi, a)
t = np.linspace(0, tmax, a)
plt.figure()
plt.ion()
plt.xlim([0, 2*np.pi])
plt.ylim([-1.2, 1.2])
plt.plot([], [])
i = 0
while i<a:
y = np.cos(t[i])*np.sin(x)
print(t[i])
plt.clf()
plt.plot(x, y)
plt.pause(1/(a*tmax))
i = i + 1
【问题讨论】:
标签: python matplotlib boundaries