import sys
import matplotlib
matplotlib.use("GTK")
import matplotlib.pyplot as plt
fig = plt.figure()
axis = fig.add_subplot(111)
def ann(text,x,y,axis):
axis.annotate(
text,
xy=(x, y),
xycoords='data',
xytext=(-100, -100),
textcoords='offset points',
arrowprops=dict(arrowstyle="->")
)
files = sys.argv[1:]
for fname in files:
file = open(fname)
line = []
time = []
first = None
last_t, last_val = None,None
for l in file.xreadlines():
t,val,val2 = l.split()
t = int(t)
val = int(val)
if not first:
first = t
t = t-first
time.append(t)
line.append(val)
if last_t:
lag = t - last_t
if lag>40:
ann("sleep",last_t,last_val,axis)
ann("resume",t,val,axis)
last_t,last_val = t,val
axis.plot(time,line)
plt.show()