-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathplot.py
64 lines (63 loc) · 1.89 KB
/
plot.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
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import numpy
import os
import multiprocessing
import com
fig = plt.figure("Rwp")
#fig.suptitle("Rwp")
axes1 = fig.add_subplot(111)
axes1.set_xlabel("step");axes1.set_ylabel("Rwp");axes1.set_title(" Rwp curve")
job=None
ani=None
rwpdata=None
jobs_s=[]
def update(d):
#line.set_xdata(data[0])
#line.set_ydata(data[1])
line, = axes1.plot(d[1],'go-',linewidth=0.3,markersize=10,markerfacecolor='red')
if os.path.exists("ok.txt"):
os.remove("ok.txt")
plt.close()
return line,
def data_gen():
#n=len(auto.rwplist)
#data=[n,auto.rwplist]
if os.path.exists("rwp.txt"):
data=numpy.loadtxt("rwp.txt")
data=data.tolist()
else:
data=[0]
data=[data,data]
rwpdata=data
yield data
def show(dg=None,cycle=1):
global data,ani;
global axes1;
#fig = plt.figure()
#axes1 = fig.add_subplot(111)
axes1.set_xlabel("step");axes1.set_ylabel("Rwp");axes1.set_title("Cycle "+str(cycle)+" Rwp curve")
if(dg==None):dg=data_gen
ani = FuncAnimation(fig, update, dg, interval=100)
plt.show()
def showrwp(s=None):
global axes1
global fig
if s == None: s="."
os.chdir(s);
cycle=com.cycle;
axes1.set_xlabel("step");axes1.set_ylabel("Rwp");axes1.set_title("Cycle "+str(cycle)+" Rwp curve")
job=multiprocessing.Process(target=show,args=(None,cycle))
job.start()
jobs_s.append(job)
def show_stable(data):
job=multiprocessing.Process(target=show_data,args=(data,com.cycle))
job.start()
jobs_s.append(job)
def show_data(rwplist,cycle=1):
line, = axes1.plot(rwplist,'go-',linewidth=0.3,markersize=10,markerfacecolor='red')
axes1.set_xlabel("step");axes1.set_ylabel("Rwp");axes1.set_title("Cycle "+str(cycle)+" Rwp curve")
plt.show()
if __name__=="__main__":
multiprocessing.freeze_support()
show()