-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
executable file
·63 lines (49 loc) · 1.52 KB
/
plot.py
File metadata and controls
executable file
·63 lines (49 loc) · 1.52 KB
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
#!/usr/bin/python
import matplotlib.pyplot as plt
import numpy as np
#from pprint import pprint as pp
def load_data(file):
with open(file) as f:
content = f.readlines()
data = []
data.append([])
data.append([])
for c in content:
line_data = c.split(" ")
data[0].append(float(line_data[0]))
data[1].append(float(line_data[1].strip("\n")))
#pp(data)
#pp(data[0])
return data
def plot(files, output_image = 'image.png', show = False):
fig, ax = plt.subplots()
#files = [files]
for f in files:
data = load_data(f)
f = f.split('.')[0].split('_')[1]
ax.plot(range(0, len(data[0])), data[0], '.', label=f)
ax.plot(range(0, len(data[1])), data[1], '')
legend = ax.legend(loc='upper right', shadow=True)
plt.xlim(0, 25000)
#plt.ylim(ymin, ymax)
plt.xlabel("Simulation number")
plt.ylabel("Fitness score")
plt.savefig(output_image)
if show:
plt.show()
data_run = []
for i in xrange(len(data[0]) / 2000 ):
data_run.append(data[0][(2000*i):(2000*(i+1))])
data_run_max = []
for d in data_run:
data_run_max.append(max(d))
print 'number of experiments: ', len(data_run_max)
print 'experiment results: ', data_run_max
print 'max: ', max(data_run_max)
print 'min: ', min(data_run_max)
print 'mean: ', np.mean(data_run_max)
print 'standard deviation: ', np.std(data_run_max)
if __name__ == "__main__":
import sys
files = sys.argv[1:]
plot(files)