質問編集履歴

6

微修正

2023/04/26 12:26

投稿

IEEzH3EH
IEEzH3EH

スコア3

test CHANGED
File without changes
test CHANGED
@@ -91,9 +91,9 @@
91
91
  ax = df.plot()
92
92
  ax.set_xlabel("Time $\it{t}$ ns",fontsize=10)
93
93
  ax.set_ylabel("Gate-Source Voltage $\it{V_{\mathsf{GS}}}}$ V",fontsize=10)
94
- df.grid()
94
+ ax.grid()
95
- df.plot()
95
+ ax.plot()
96
96
  ```
97
97
 
98
98
  実行結果(目的のグラフを描画できた):
99
- ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-04-26/0ff8f5d1-3853-42ef-a3cc-d57d52bfde25.png)
99
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-04-26/fd42339b-b60d-4cb6-bc69-c7e899b24c30.png)

5

目的のグラフを得られた。最終修正版。

2023/04/26 12:22

投稿

IEEzH3EH
IEEzH3EH

スコア3

test CHANGED
File without changes
test CHANGED
@@ -78,3 +78,22 @@
78
78
 
79
79
  再度修正したプログラムの2回目の実行結果:
80
80
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-04-26/4934ee2a-3637-4fd4-b25e-2269b27f7713.png)
81
+
82
+
83
+ 最終的なプログラム(回答者様のコードをCSVを取り込められるように改変):
84
+ ```Python
85
+ import pandas as pd
86
+ import matplotlib.pyplot as plt
87
+
88
+ #CSVファイルをUTF-8形式で読み込む
89
+
90
+ df = pd.read_csv('000.csv',encoding = 'UTF8', index_col='time')
91
+ ax = df.plot()
92
+ ax.set_xlabel("Time $\it{t}$ ns",fontsize=10)
93
+ ax.set_ylabel("Gate-Source Voltage $\it{V_{\mathsf{GS}}}}$ V",fontsize=10)
94
+ df.grid()
95
+ df.plot()
96
+ ```
97
+
98
+ 実行結果(目的のグラフを描画できた):
99
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-04-26/0ff8f5d1-3853-42ef-a3cc-d57d52bfde25.png)

4

再度プログラムを修正

2023/04/26 12:06

投稿

IEEzH3EH
IEEzH3EH

スコア3

test CHANGED
File without changes
test CHANGED
@@ -55,3 +55,26 @@
55
55
 
56
56
  修正したプログラムの結果:
57
57
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-04-26/7f2ebd73-5897-429a-96c5-e7d4feb28e0c.png)
58
+
59
+
60
+ 再度修正したプログラム:
61
+ ```Python
62
+ import pandas as pd
63
+ import matplotlib.pyplot as plt
64
+
65
+ #CSVファイルをUTF-8形式で読み込む
66
+
67
+ df = pd.read_csv('000.csv',encoding = 'UTF8', index_col='time')
68
+ plt.xlabel("Time $\it{t}$ ns",fontsize=22)
69
+ plt.ylabel("Gate-Source Voltage $\it{V_{\mathsf{GS}}}}$ V",fontsize=22)
70
+ #dataを出力
71
+ plt.grid()
72
+ df.plot()
73
+ ```
74
+
75
+
76
+ 再度修正したプログラムの1回目の実行結果:
77
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-04-26/6652e768-4b46-468d-bd3c-553bed4c1ff1.png)
78
+
79
+ 再度修正したプログラムの2回目の実行結果:
80
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-04-26/4934ee2a-3637-4fd4-b25e-2269b27f7713.png)

3

修正した結果のついか

2023/04/26 11:34

投稿

IEEzH3EH
IEEzH3EH

スコア3

test CHANGED
File without changes
test CHANGED
@@ -37,3 +37,21 @@
37
37
 
38
38
 
39
39
  ```
40
+
41
+ 修正したプログラム(今度はデータを描画できない):
42
+ ```Python
43
+ import pandas as pd
44
+ import matplotlib.pyplot as plt
45
+
46
+ #CSVファイルをUTF-8形式で読み込む
47
+
48
+ df = pd.read_csv('000.csv',encoding = 'UTF8', index_col='time')
49
+ plt.xlabel("Time $\it{t}$ ns",fontsize=22)
50
+ plt.ylabel("Gate-Source Voltage $\it{V_{\mathsf{GS}}}}$ V",fontsize=22)
51
+ #dataを出力
52
+ #plt.grid()
53
+ plt.plot()
54
+ ```
55
+
56
+ 修正したプログラムの結果:
57
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-04-26/7f2ebd73-5897-429a-96c5-e7d4feb28e0c.png)

2

グリッドの表示について

2023/04/26 11:02

投稿

IEEzH3EH
IEEzH3EH

スコア3

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,5 @@
1
1
  時間と電圧に関するCSVファイルをグラフ化したいのですが、横軸・縦軸に軸名を表示できないです。
2
+ またグリッドの表示もうまくできないです。
2
3
 
3
4
  グラフ描画したいデータ:
4
5
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-04-26/bc409fda-7ee4-4394-b4e3-3b02a5a42440.png)

1

実行結果(エラー)の追加

2023/04/26 10:56

投稿

IEEzH3EH
IEEzH3EH

スコア3

test CHANGED
File without changes
test CHANGED
@@ -17,3 +17,22 @@
17
17
  #plt.grid()
18
18
  plt.plot()
19
19
  ```
20
+
21
+ 実行結果:
22
+ ```Python
23
+ runfile('C:/Users/ISDka/.spyder-py3/testCSV.py', wdir='C:/Users/ISDka/.spyder-py3')
24
+ Traceback (most recent call last):
25
+
26
+ File C:\anaconda\lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
27
+ exec(code, globals, locals)
28
+
29
+ File c:\users\isdka\.spyder-py3\testcsv.py:7
30
+ plt.xlabel("Drain Voltage $\it{V_{\mathsf{DS}}}$ V",fontsize=22)
31
+
32
+ File C:\anaconda\lib\site-packages\pandas\core\generic.py:5902 in __getattr__
33
+ return object.__getattribute__(self, name)
34
+
35
+ AttributeError: 'DataFrame' object has no attribute 'xlabel'
36
+
37
+
38
+ ```