I'm new to python and matplotlib and need a few pointers. I'm trying to write a monitor that queries a table and plots the results. from the table I can extract a timestamp I'd like to use for the X axis and a #of seconds I'd like to use for the Y value (number of packets sent). I'm not sure where "i" is populated for the animate function. My plot comes up but is empty. I'm not sure what ax.set_xlim should be set to and finally how do I get the date/timestamp to show up on the x-axis? Im trying to modify the following example:
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation
fig = plt.figure()
ax = plt.axes(ylim=(0, 45))
line, = ax.plot([], [], lw=5)
def init():
line.set_data([], [])
return line,
def animate(i):
x,y,dk=getData()
line.set_data(x, y)
return line,
def Execute():
#anim = animation.FuncAnimation(fig, animate, init_func=init, frames=200, interval=200, blit=True)
anim = animation.FuncAnimation(fig, animate, init_func=init, frames=200, interval=2000)
plt.show()
return(anim)
def getDataSql(sql):
... run sql
return(rl)
def getData():
...format return for getDataSql
...return X ex(2013-04-12 18:18:24) and Y ex(7.357) (both are lists)
return(X,Y,xy)
x=Execute()