-
Notifications
You must be signed in to change notification settings - Fork 4
/
susan_scratch.py
73 lines (59 loc) · 1.61 KB
/
susan_scratch.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib import style
import time
from tqdm import tqdm
import numpy as np
##plt.ion() #look into multithreading this
#style.use('fivethirtyeight')
#fig = plt.figure()
#ax1 = fig.add_subplot(1,1,1)
#plt.ylabel('convergence')
#plt.xlabel('iteration')
def run(self):
y = counter(10)
print(y)
def counter(n):
y0 = np.array([1,2,3])
style.use('fivethirtyeight')
fig = plt.figure()
ax1 = fig.add_subplot(1,2,1)
plt.ylabel('convergence')
plt.xlabel('iteration')
plt.xlim(0,n)
ax2 = fig.add_subplot(1,2,2)
plt.ylabel('test')
plt.xlabel('iteration')
#plt.yscale('log')
#plt.text(2,4,"0")
plt.xlim(0,n)
#plt.ylim(0,12)
test = []
for i in tqdm(range(n)):
y = 10.0-i*y0
if i == 0:
test = np.min(y)
# else:
# test.append(test[i-1])
progress(i,y,ax1,ax2,n,test)
print(np.min(y))
plt.show()
return y
def progress(i,y,ax1,ax2,n,test):
# if i==1:
#style.use('fivethirtyeight')
#fig = plt.figure()
#ax1 = fig.add_subplot(1,1,1)
#plt.ylabel('convergence')
#plt.xlabel('iteration')
# else:
err_range = (np.amax(y) - np.amin(y))/2.0
ax1.errorbar(i, np.mean(y), yerr=err_range, fmt='o')
#ax2.text(n,4,np.amin(y),bbox=dict(facecolor='white', alpha=1))
ax2.text(n-1, test-1, np.amin(y),
bbox=dict(facecolor='white', alpha=1))
ax2.scatter(i,np.amin(y),c=[0,0,0])
#ax2.text()
plt.pause(0.5) #time it waits for plot to update
y = counter(4)
print(y)