Let's get started.
Unlike the previous post, let's create the data and plot it as it is generated.
$ cat rtPlot
#!/usr/bin/python
from pylab import *;
import time;
def log(M):
print "__(log) " + M;
def test01():
plt.ion();
fig=plt.figure(1);
ax1=fig.add_subplot(111);
l1,=ax1.plot(100,100,'r-');
time.sleep(2.0);
D=[];
i=0.0;
while (i < 50.0):
D.append((i,sin(i)));
T=[x[0] for x in D];
L=[x[1] for x in D];
l1.set_xdata(T);
l1.set_ydata(L);
ax1.relim();
ax1.autoscale_view();
plt.draw();
i+=0.10;
time.sleep(1/10.0);
show(block=True);
#---main---
log("main process initializing");
test01();
log("main process terminating");
Tie this plotting routine to a system providing run-time information via a socket, or perhaps monitoring network traffic via pcapture libraries and you've got yourself the foundation of a real-time data monitoring system.
Cheers.
No comments:
Post a Comment