import sys import matplotlib matplotlib use GTK import matplotlib pypl

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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()