-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgraph.py
36 lines (33 loc) · 970 Bytes
/
graph.py
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
import os
import random
import time
import Gnuplot
def graph(myitems, out_name):
tmp_name = out_name+".tmp"+str(random.randrange(2**24))
g = Gnuplot.Gnuplot(debug=1)
g("set terminal png size 600,400 nocrop x000000 xA9A9A9 xA9A9A9 xFF0000 x00FF00 x0000FF")
g("set border 3")
g("set xtics nomirror")
g("set ytics nomirror")
g.set_string("output", tmp_name)
g.xlabel('Size in GB')
g.ylabel('GB/$');
g("set style line 1 lc 1")
g("set style line 2 lc 2")
g("set style line 3 lc 3")
g("set style line 4 lc 4")
l = []
for i, (k, v) in enumerate(myitems):
if v:
params = {}
params['with'] = "points ls %i" % (i+1)
if k:
params['title'] = k
print i, len(v)
l.append(Gnuplot.Data(v, **params))
if l:
g.plot(*l)
g.close()
while not os.path.exists(tmp_name):
time.sleep(1)
os.rename(tmp_name, out_name)