如果初始帧中的所有条目都包含相同的值,我似乎无法获得图像的TimedAnimation
动画来显示任何内容。例如,如果指示的行仍被注释掉,则以下内容不会显示任何内容。将第一帧更改为包含np.ones(self.shape)
也没有任何效果。你知道吗
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as anim
class MyAnimation(anim.TimedAnimation):
def __init__(self):
fig = plt.figure()
self.shape = (10, 10)
data = np.zeros(self.shape)
# data.flat[0] = 1 # uncomment this to get the animation to display
self.ax = plt.imshow(data)
super(self.__class__, self).__init__(fig, interval=50, blit=True)
def _draw_frame(self, framedata):
data = np.random.rand(*self.shape)
self.ax.set_data(data)
def new_frame_seq(self):
return iter(range(100))
ani = MyAnimation()
关闭blitting似乎没有任何效果。更改后端似乎也没有任何区别;我尝试了Qt4Agg和nbagg(后者通过jupyternotebook4.1.0实现),得到了相同的结果。我在python2.7.11中使用numpy1.10.4和matplotlib1.5.1。你知道吗
是否预期出现上述行为?如果没有,我应该做些什么让动画显示时,第一帧是空白或固体图像?你知道吗
设置数据不会重新计算颜色限制。在所有输入值相同的情况下,最小/最大值将自动缩放为相同的值,因此您永远不会看到数据被更新。您可以在init上显式设置限制
或者在
_draw_frame
方法中使用self.im.set_clim
。你知道吗我也不确定亚分类
TimedAnimation
是做任何你想做的事情的最简单的方法(FuncAnimation
是非常灵活的)。你知道吗相关问题 更多 >
编程相关推荐