python - 动态动画图表不使用 matlibplot.animation
问题描述
我试图将图表链接到动态保存的 csv,但动画功能似乎不起作用。我的代码如下,谢谢:
self.f = open("data.csv","r")
fig,ax1 = plt.subplots()
ax2 = ax1.twinx()
self.data = np.loadtxt(self.f, delimiter = ",", skiprows = 1)
self.y = self.data[:,5] - self.data[:,6]
self.z1 = self.data[:,2] - self.data[:,1]
c = self.z1.size
self.t = np.arange(0, c, 1)
ax1.plot(self.t, self.y,'g-')
ax2.plot(self.t, self.z1,'b-')
anim = ani.FuncAnimation(self.fig, self.animate, interval=1000)
plt.show()
def animate(self,i):
self.f = open("data.csv","r")
self.data = np.loadtxt(self.f, delimiter = ",", skiprows = 1)
self.y = self.data[:,5] - self.data[:,6]
self.z1 = self.data[:,2] - self.data[:,1]
c = self.z1.size
self.t = np.arange(0, c, 1)
解决方案
推荐阅读
- javascript - javascript中的curl -u请求
- c# - 在 C# 中使用 linq 查询比较两个字典键
- wordpress - 木材是否有像 404 一样的默认 500 模板?
- amazon-web-services - 已删除 AWS CodeBuild 分支过滤器选项
- c# - 检查对象列表是否包含特定值
- asp.net - 路由 IIS - Angular - Asp.Net Core
- mayavi - 如何修复 Mayavi contour3d?
- go - 我需要在 XORM 中关闭 sqlite3 数据库连接吗?
- php - 下一个按钮在代码 php 的按钮中不起作用
- python - 为什么 os.system 会阻止程序执行?