文本“Fx+Test1.txt” 内容如下:第一列是序号,第二列砝码重量(N),后三列是三路电压输出(V)
1 0 0.3912 -0.3061 -0.3535
2 0 0.3913 -0.3062 -0.3534
3 0 0.3912 -0.3062 -0.3534
4 0 0.3913 -0.3062 -0.3535
5 0 0.3913 -0.3062 -0.3535
6 0 0.3913 -0.3062 -0.3535
7 0 0.3913 -0.3062 -0.3535
8 0 0.3912 -0.3062 -0.3536
9 0 0.3912 -0.3061 -0.3536
10 0 0.3913 -0.3063 -0.3536
11 2 0.3896 -0.3165 -0.3353
12 2 0.3895 -0.3165 -0.3352
13 2 0.3896 -0.3164 -0.3352
14 2 0.3898 -0.3167 -0.3353
15 2 0.3896 -0.3166 -0.3353
16 2 0.3895 -0.3164 -0.3351
17 2 0.3896 -0.3165 -0.3353
18 2 0.3894 -0.3164 -0.3351
19 2 0.3896 -0.3168 -0.3352
20 2 0.3895 -0.3165 -0.3352
21 4 0.3883 -0.3258 -0.3161
22 4 0.3883 -0.3258 -0.3162
23 4 0.3883 -0.3258 -0.3163
24 4 0.3882 -0.3256 -0.3163
25 4 0.3882 -0.3257 -0.3163
26 4 0.3883 -0.3257 -0.3164
27 4 0.3884 -0.3256 -0.3165
28 4 0.3884 -0.3256 -0.3165
29 4 0.3884 -0.3257 -0.3167
30 4 0.3885 -0.3257 -0.3168
31 6 0.3872 -0.3357 -0.297
32 6 0.3875 -0.3356 -0.297
33 6 0.3879 -0.3355 -0.297
34 6 0.3876 -0.3358 -0.2971
35 6 0.387 -0.3356 -0.297
36 6 0.3876 -0.3356 -0.297
37 6 0.3874 -0.3358 -0.297
38 6 0.387 -0.3355 -0.2969
39 6 0.3875 -0.3355 -0.2969
40 6 0.3874 -0.3357 -0.2969
41 8 0.3869 -0.3469 -0.2773
42 8 0.3868 -0.3466 -0.2772
43 8 0.3866 -0.3472 -0.2773
44 8 0.3867 -0.3476 -0.2774
45 8 0.3868 -0.3478 -0.2773
46 8 0.3869 -0.3472 -0.2772
47 8 0.3868 -0.347 -0.2772
48 8 0.3867 -0.3466 -0.2771
49 8 0.3866 -0.3474 -0.2773
50 8 0.3868 -0.347 -0.2772
51 10 0.3854 -0.36 -0.2581
52 10 0.3859 -0.3597 -0.2581
53 10 0.3869 -0.3591 -0.2581
54 10 0.3865 -0.3592 -0.2581
55 10 0.3857 -0.3595 -0.2581
56 10 0.3857 -0.3599 -0.2582
57 10 0.3865 -0.3596 -0.2582
58 10 0.3868 -0.3591 -0.2581
59 10 0.3854 -0.3596 -0.2582
60 10 0.3863 -0.3597 -0.2581
61 12 0.385 -0.3733 -0.2388
62 12 0.3856 -0.3738 -0.239
63 12 0.3859 -0.3742 -0.2389
64 12 0.3855 -0.3737 -0.2389
65 12 0.3857 -0.3731 -0.2387
66 12 0.3862 -0.3739 -0.2389
67 12 0.3857 -0.3739 -0.2389
68 12 0.3852 -0.3733 -0.2387
69 12 0.3861 -0.3736 -0.2388
70 12 0.3863 -0.3739 -0.239
71 14 0.3853 -0.3887 -0.2195
72 14 0.3851 -0.3884 -0.2193
73 14 0.3847 -0.3882 -0.2194
74 14 0.3849 -0.3886 -0.2194
75 14 0.3853 -0.3887 -0.2194
76 14 0.3848 -0.3883 -0.2193
77 14 0.3848 -0.3885 -0.2192
78 14 0.3851 -0.3887 -0.2194
79 14 0.3852 -0.3885 -0.2193
80 14 0.385 -0.3885 -0.2192
81 16 0.3848 -0.4069 -0.1996
82 16 0.3841 -0.406 -0.1995
83 16 0.3846 -0.406 -0.1995
84 16 0.3849 -0.4068 -0.1996
85 16 0.3844 -0.4068 -0.1996
86 16 0.3845 -0.4059 -0.1994
87 16 0.3849 -0.4065 -0.1996
88 16 0.3841 -0.4065 -0.1995
89 16 0.3844 -0.406 -0.1995
90 16 0.3851 -0.4064 -0.1996
91 18 0.384 -0.4241 -0.1809
92 18 0.3842 -0.424 -0.1808
93 18 0.3843 -0.4239 -0.1807
94 18 0.3841 -0.4238 -0.1808
95 18 0.3839 -0.4239 -0.1808
96 18 0.3842 -0.4239 -0.1808
97 18 0.3843 -0.4238 -0.1808
98 18 0.3842 -0.4236 -0.1807
99 18 0.3839 -0.4237 -0.1808
100 18 0.3843 -0.4237 -0.1807
101 20 0.3837 -0.4413 -0.1608
102 20 0.3839 -0.4417 -0.1609
103 20 0.3841 -0.4419 -0.1608
104 20 0.384 -0.4415 -0.1608
105 20 0.3836 -0.441 -0.1607
106 20 0.3834 -0.4407 -0.1607
107 20 0.3835 -0.441 -0.1608
108 20 0.3839 -0.4415 -0.1609
109 20 0.3841 -0.4418 -0.161
110 20 0.3841 -0.4415 -0.1609
111 20 0.3838 -0.441 -0.1608
112 20 0.3835 -0.4406 -0.1608
113 20 0.3834 -0.4408 -0.1607
114 20 0.3838 -0.4412 -0.1608
115 20 0.384 -0.4415 -0.1609
116 20 0.3837 -0.441 -0.1608
117 20 0.3835 -0.4406 -0.1607
118 20 0.3839 -0.4415 -0.1608
119 20 0.3841 -0.4416 -0.1607
120 20 0.3838 -0.4413 -0.1607
121 18 0.3841 -0.425 -0.1806
122 18 0.3842 -0.4249 -0.1806
123 18 0.3842 -0.4248 -0.1806
124 18 0.3842 -0.4247 -0.1806
125 18 0.3842 -0.4248 -0.1806
126 18 0.3842 -0.4249 -0.1805
127 18 0.3841 -0.4248 -0.1805
128 18 0.3843 -0.4247 -0.1805
129 18 0.3843 -0.4248 -0.1804
130 18 0.3841 -0.4247 -0.1804
131 16 0.3843 -0.4073 -0.2011
132 16 0.3845 -0.4074 -0.2013
133 16 0.3848 -0.4077 -0.2014
134 16 0.3851 -0.4082 -0.2014
135 16 0.3847 -0.4079 -0.2013
136 16 0.3844 -0.4073 -0.2012
137 16 0.3847 -0.4078 -0.2014
138 16 0.385 -0.4081 -0.2015
139 16 0.3845 -0.4075 -0.2013
140 16 0.3844 -0.4073 -0.2012
141 14 0.3854 -0.3899 -0.2206
142 14 0.3856 -0.391 -0.2208
143 14 0.3851 -0.391 -0.2208
144 14 0.385 -0.389 -0.2204
145 14 0.3852 -0.3893 -0.2203
146 14 0.3853 -0.3914 -0.2206
147 14 0.3848 -0.3902 -0.2205
148 14 0.3852 -0.3893 -0.2203
149 14 0.3855 -0.3901 -0.2205
150 14 0.3848 -0.3904 -0.2204
151 12 0.386 -0.3735 -0.2411
152 12 0.3861 -0.3735 -0.2411
153 12 0.386 -0.3736 -0.2411
154 12 0.3854 -0.3738 -0.2412
155 12 0.3854 -0.3737 -0.2411
156 12 0.3857 -0.3736 -0.2411
157 12 0.3857 -0.3738 -0.2411
158 12 0.3854 -0.3738 -0.2411
159 12 0.3854 -0.3738 -0.2411
160 12 0.3859 -0.3735 -0.2409
161 10 0.3869 -0.3575 -0.2598
162 10 0.3866 -0.3578 -0.2599
163 10 0.386 -0.358 -0.2598
164 10 0.3859 -0.357 -0.2597
165 10 0.3863 -0.3571 -0.2596
166 10 0.3867 -0.3575 -0.2597
167 10 0.3867 -0.3579 -0.2597
168 10 0.386 -0.358 -0.2597
169 10 0.3856 -0.3573 -0.2596
170 10 0.3867 -0.3571 -0.2596
171 8 0.3864 -0.3424 -0.2791
172 8 0.3864 -0.3426 -0.2792
173 8 0.3867 -0.3422 -0.2793
174 8 0.3868 -0.3423 -0.2793
175 8 0.3864 -0.3426 -0.2794
176 8 0.386 -0.3429 -0.2794
177 8 0.3863 -0.3428 -0.2793
178 8 0.3867 -0.3424 -0.2793
179 8 0.3871 -0.342 -0.2793
180 8 0.3866 -0.3424 -0.2793
181 6 0.3864 -0.3295 -0.2987
182 6 0.3863 -0.3298 -0.2988
183 6 0.3863 -0.3298 -0.2988
184 6 0.3875 -0.33 -0.2989
185 6 0.3877 -0.3297 -0.2988
186 6 0.3873 -0.3294 -0.2988
187 6 0.3867 -0.3292 -0.2987
188 6 0.3866 -0.33 -0.2989
189 6 0.3876 -0.3293 -0.2988
190 6 0.3864 -0.3294 -0.2987
191 4 0.3875 -0.3205 -0.319
192 4 0.3875 -0.3206 -0.319
193 4 0.3876 -0.3205 -0.319
194 4 0.3877 -0.3206 -0.319
195 4 0.3877 -0.3206 -0.319
196 4 0.3875 -0.3206 -0.3191
197 4 0.3874 -0.3206 -0.3191
198 4 0.3876 -0.3207 -0.319
199 4 0.3876 -0.3206 -0.319
200 4 0.3875 -0.3206 -0.3191
201 2 0.3881 -0.3112 -0.3384
202 2 0.388 -0.3112 -0.3385
203 2 0.3879 -0.3111 -0.3384
204 2 0.3879 -0.311 -0.3383
205 2 0.388 -0.3111 -0.3384
206 2 0.388 -0.3111 -0.3385
207 2 0.3881 -0.3111 -0.3384
208 2 0.3881 -0.3112 -0.3385
209 2 0.3878 -0.3111 -0.3383
210 2 0.388 -0.3112 -0.3383
211 0 0.3885 -0.301 -0.3587
212 0 0.3885 -0.301 -0.3587
213 0 0.3885 -0.3011 -0.3587
214 0 0.3885 -0.3009 -0.3586
215 0 0.3885 -0.3008 -0.3586
216 0 0.3885 -0.3009 -0.3586
217 0 0.3885 -0.3009 -0.3587
218 0 0.3884 -0.3009 -0.3587
219 0 0.3885 -0.3009 -0.3586
220 0 0.3884 -0.301 -0.3586
利用numpy库的loadtxt函数读取文本,subplot函数参数1表示第几个子图,第二个参数axisbg表示子图的背景色:
import matplotlib.pyplot as plt
import numpy as np
data = np.loadtxt('Fx+Test1.txt')
legend=['Uy','Uz','Ux']
for idx,color in enumerate('rgy'):
plt.subplot(221+idx,axisbg=color)
plt.plot(data[:,1], data[:,idx+2],'o',label=legend[idx])
plt.xlabel("Force(N)")
plt.ylabel("Volt(V)")
plt.legend()
plt.show()
运行结果: