-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotter.py
executable file
·50 lines (34 loc) · 1007 Bytes
/
plotter.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python3
import matplotlib.pyplot as plt
from os import remove as rm_file
file_name = 'error_list_to_plot'
def fileReader ():
file = open(file_name, 'r')
error_list = []
line = file.readline()
minimum = float(line)
maximum = float(line)
while line != '':
error_list.append(float(line))
if (float(line) < minimum): minimum = float(line)
if (float(line) > maximum): maximum = float(line)
line = file.readline()
if minimum > 0:
minimum = 0
return error_list, minimum, maximum
def plotter (error_list, minimum, maximum):
plt.plot(error_list, label = 'linear')
low_bound = minimum
if (low_bound != 0):
low_bound *= 1.05
axes = plt.gca()
axes.set_ybound([low_bound, maximum*1.1])
plt.xlabel("iteration")
plt.ylabel("error")
plt.title("training results")
plt.show()
def main ():
error_list, minimum, maximum = fileReader()
plotter(error_list, minimum, maximum)
rm_file(file_name)
main()