python matlabplot animate 刷新_如何使用matplotlib更新图形

Jake Vanderplas的教程中的这个例子可能是

matplotlib动画:from __future__ import division

import numpy as np

import matplotlib.pyplot as plt

import matplotlib.animation as animation

def init():

return [line]

def animate(i, ax, line):

x = np.linspace(0, 2*np.pi, N) + i/(N*2)

ax.set_xlim(x.min(), x.max())

line.set_data(x, np.sin(x))

return [line]

N = 100

fig, ax = plt.subplots()

line, = ax.plot([], [])

ax.set_xlim(0, 2*np.pi)

ax.set_ylim(-1, 1)

ani = animation.FuncAnimation(

fig, animate, init_func=init, interval=0, frames=int(4*np.pi*N),

repeat=True, blit=True, fargs=[ax, line])

plt.show()

更改不同的值或代码行,看看会发生什么。看看如果

{cd1>换点别的。如果你学习和玩这些

举例来说,你可以学习这些部分是如何组合在一起的。在

一旦你理解了这个例子,你应该能够修改它来适应你的

目标。在

如果有问题,请发布代码并描述错误消息或

你看,行为不端。在

一些提示:因为动画需要调用line.set_data,所以我不认为你

可以使用熊猫的df.plot()。事实上,我不确定熊猫数据帧是否

这里有用。最好将数据吸入列表或NumPy数组中

像上面一样把它们传给{},而不让熊猫参与。

打开到数据库的连接应该完成一次。animate得到

打了很多次电话。所以最好定义conn和c和query任何不随animate调用而改变的内容

在animate之外,并通过

fargs参数。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值