Statistics
| Branch: | Revision:

nepatest_popbabel / scripts / plotterCentr.py @ 60ba786f

History | View | Annotate | Download (948 Bytes)

1
import sys
2
import numpy as np
3
import matplotlib.pyplot as plt
4
from dateutil.parser import parse
5
import datetime
6

    
7
finput=""
8
print sys.argv[1]
9
finput=sys.argv[1]
10
fname=""
11
with open (finput, "r") as myfile:
12
        fname=myfile.name.split(".")[0]
13
        data=myfile.readlines()
14

    
15
xtime=[]
16
ycentrality=[]
17

    
18
for l in data:
19
        spl=l.split(',')
20
        cent=spl[-1]
21
        tval=float(spl[1])
22
        spl=spl[0].split('.')
23
        d = datetime.datetime.strptime(spl[0], "%H:%M:%S")
24
        #print (d - datetime.datetime(1970,1,1)).total_seconds()
25
        spl=spl[0].split(':')
26
        sec=spl[-1]
27
        minutes=spl[-2]
28
        hours=spl[-3]
29
        #print hours,minutes,sec
30
        time= int(hours) * 60 * 60 + int(minutes)*60 + int(sec) + 0.000001 * int(spl[-1])
31
        
32
        xtime.append(tval)
33
        ycentrality.append(int(cent))
34

    
35
#print xtime
36
plt.plot(xtime, ycentrality)
37
plt.grid(True)
38
plt.xlabel('relative time')
39
plt.ylabel('Babel Centrality index')
40
ymin, ymax = plt.ylim()
41
ml=ymax+1
42
plt.ylim(ymin,ml)
43
fig = plt.gcf()
44
plt.show()
45
fig.savefig(""+fname+".pdf")