回答編集履歴

2

d

2019/08/07 15:44

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -14,13 +14,19 @@
14
14
 
15
15
  fig, ax = plt.subplots(figsize=(4, 6))
16
16
 
17
+ ax.set_xlim(-3, 3)
18
+
19
+ ax.set_ylim(0, 0.0055)
20
+
21
+ ax.set_xlabel("Voltage [V]")
22
+
23
+ ax.set_ylabel("Current[A]")
24
+
17
25
 
18
26
 
19
27
  for file in file_list:
20
28
 
21
29
  data01_axis1, data01_value1 = np.loadtxt(file, unpack=True)
22
-
23
-
24
30
 
25
31
  da = data01_axis1
26
32
 
@@ -29,14 +35,6 @@
29
35
 
30
36
 
31
37
  ax.plot(da, dv, "o-", color="k", label="value1 of data01")
32
-
33
- ax.set_xlim(-3, 3)
34
-
35
- ax.set_ylim(0, 0.0055)
36
-
37
- ax.set_xlabel("Voltage [V]")
38
-
39
- ax.set_ylabel("Current[A]")
40
38
 
41
39
 
42
40
 

1

d

2019/08/07 15:44

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -1 +1,49 @@
1
- `plt.show()` は for ループの外に出して、コードの最後に1回だけ実行するようにしてみてください。
1
+ `plt.figure()` や `plt.show()` は for ループの外に出してください。
2
+
3
+
4
+
5
+ ```python
6
+
7
+ import glob
8
+
9
+
10
+
11
+ file_list = glob.glob(r"C:\Users\user\Desktop\test*.txt")
12
+
13
+
14
+
15
+ fig, ax = plt.subplots(figsize=(4, 6))
16
+
17
+
18
+
19
+ for file in file_list:
20
+
21
+ data01_axis1, data01_value1 = np.loadtxt(file, unpack=True)
22
+
23
+
24
+
25
+ da = data01_axis1
26
+
27
+ dv = data01_value1
28
+
29
+
30
+
31
+ ax.plot(da, dv, "o-", color="k", label="value1 of data01")
32
+
33
+ ax.set_xlim(-3, 3)
34
+
35
+ ax.set_ylim(0, 0.0055)
36
+
37
+ ax.set_xlabel("Voltage [V]")
38
+
39
+ ax.set_ylabel("Current[A]")
40
+
41
+
42
+
43
+ plt.show()
44
+
45
+ ```
46
+
47
+
48
+
49
+ データはないため、動作は未確認。