有没有办法让它在matplotlib上制作的情节会像电影一样循环?如果我有12个不同的情节并让它显示第一个10秒,那么下一个等等,然后在最后一个之后重复?由于我想要显示的图表数量,我想这样做作为子图的替代。
答案 0 :(得分:3)
是,使用带有class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :receipts
validate :first_name, presence: true
validate :last_name, presence: true
validate :email, presence: true, email: true
end
的动画模块,并修改repeat = True
参数以控制绘图之间的时间。
interval
以这种方式使用import matplotlib.animation as animation
fig = plt.figure()#
data_, = plot([], [])
def data_gen():
while i < NUMBER_OF_PLOTS:
'''
make your instance of X data in a list called YOUR_X_DATA
and your Y data in a list called YOUR_Y_DATA
and iterate along it.
'''
yield YOUR_X_DATA[i], YOUR_Y_DATA[i]
i+=1
def run(data):
data_.set_data(data[0], data[1])
ani = animation.FuncAnimation(fig , run, data_gen, interval=100,repeat=True)
plt.show()
和time.sleep(10)
或
plt.close(fig)