-
Notifications
You must be signed in to change notification settings - Fork 5
/
txtDataPlot.py
105 lines (63 loc) · 2.52 KB
/
txtDataPlot.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import matplotlib.pyplot as plt #导入matplot绘图库
#-----------------------------------------------------------------------------
'''导入x数据'''
f1 = open(r'/Users/wangwei/Desktop/cuda/data/x.txt','r')
lines = f1.readlines()
x = [float(line.strip()) for line in lines] #string经过strip或split处理后强制转化为float组成list
f1.close()
#-----------------------------------------------------------------------------
print('1.Gx 2.Fx 3.Jm 4.exit')
choice = int(input("Input:"))
if choice == 4:
exit()
mode = input("Injection Mode:")
R = input("R:")
if choice == 1:
rs = R.strip().split()
plt.figure(figsize=(8,6), dpi=100)
for r in rs:
f2 = open(r'/Users/wangwei/Desktop/cuda/data/Gx/Gx_mode({})/gx-mode({})R({}).txt'.format(mode,mode,r),'r')
lines = f2.readlines()
y = [float(line.strip()) for line in lines]
f2.close()
plt.plot(x, y, label="R={}".format(r), linewidth=2)
plt.xlabel("x/μm")
plt.ylabel("gx")
plt.legend()
plt.savefig(r'/Users/wangwei/Documents/Python/plot/figures/gx-mode({})R({}).png'.format(mode,R), dpi=100)
elif choice == 2:
Beta = input("Beta:")
betas = Beta.strip().split()
plt.figure(figsize=(8,6), dpi=150)
for beta in betas:
f2 = open(r'/Users/wangwei/Desktop/cuda/data/Fx/Fx_injectionmode{}/Fx_R{}/Fx_Beta{}/0-Fx-mode({})R({})Beta({})dBeta(0).txt'.format(mode,R,beta,mode,R,beta),'r')
lines = f2.readlines()
y = [float(line.strip()) for line in lines]
f2.close()
plt.plot(x, y, label="Beta={}".format(beta), linewidth=1.5)
plt.xlabel("x/μm")
plt.ylabel("fx")
plt.legend()
plt.savefig(r'/Users/wangwei/Documents/Python/plot/figures/fx-mode({})R({})Beta({}).png'.format(mode,R,Beta), dpi=150)
elif choice == 3:
Beta = input("Beta:")
betas = Beta.strip().split()
plt.figure(figsize=(8,6), dpi=150)
for beta in betas:
f2 = open(r'/Users/wangwei/Desktop/cuda/data/jm/jm_injectionmode{}/jm_R{}/jm_Beta{}/0-jm-mode({})R({})Beta({})dBeta(0).txt'.format(mode,R,beta,mode,R,beta),'r')
lines = f2.readlines()
y = [float(line.strip()) for line in lines]
f2.close()
plt.plot(x, y, label="beta={}".format(beta), linewidth=1.5)
plt.xlabel("x/μm")
plt.ylabel("jm")
plt.legend()
plt.savefig(r'/Users/wangwei/Documents/Python/plot/figures/jm-mode({})R({})Beta({}).png'.format(mode,R,Beta), dpi=150)
print('Done.\n')
#-----------------------------------------------------------------------------
#Mac下python的清屏命令
'''
import os
os.system("clear")
'''
#-----------------------------------------------------------------------------