質問編集履歴

4

修正

2017/11/08 06:13

投稿

bkts94441
bkts94441

スコア18

test CHANGED
File without changes
test CHANGED
@@ -68,7 +68,7 @@
68
68
 
69
69
  df[df['label']==l].plot(x='freq', y='amp', label=l, c=colors[l], ax=ax)
70
70
 
71
- #plt.legend(file.split(os.sep)[-3]) *日付ファイルのラベル表記
71
+ #plt.legend(file.split(os.sep)[-3]) #日付ファイルのラベル表記
72
72
 
73
73
  ax.grid(True)
74
74
 

3

更新

2017/11/08 06:13

投稿

bkts94441
bkts94441

スコア18

test CHANGED
File without changes
test CHANGED
@@ -18,11 +18,11 @@
18
18
 
19
19
  ```ここに言語を入力
20
20
 
21
- # coding: UTF-8
22
-
23
21
  import matplotlib.pyplot as plt
24
22
 
25
23
  import pandas as pd
24
+
25
+ import numpy as np
26
26
 
27
27
  import os
28
28
 
@@ -34,21 +34,53 @@
34
34
 
35
35
  def GraphSortOverlap():
36
36
 
37
- files = glob.glob("./target.csv")
37
+ files = glob.glob("./*/data/target.csv")#*は日付ファイル
38
+
39
+ N = len(files)
38
40
 
39
41
  list =[]
40
42
 
41
- for file in files:
43
+ for idx, file in enumerate(files):
42
44
 
45
+ # FILE毎にUNIQUEなLABELを追加
46
+
43
- list.append(pd.read_csv(file))
47
+ df = pd.read_csv(file)
48
+
49
+ df['label'] = idx
50
+
51
+ list.append(df)
44
52
 
45
53
  df = pd.concat(list)
46
54
 
55
+
56
+
57
+ # LABEL 0~(N-1) に対応したColorリストを生成
58
+
59
+ colors = plt.cm.jet(np.linspace(0,1,N))
60
+
61
+
62
+
63
+ ax = plt.subplot()
64
+
65
+ # LABEL毎にグラフを描写
66
+
67
+ for l in range(N):
68
+
47
- df.plot(x = 'row' , y = 'col' ,grid=True)
69
+ df[df['label']==l].plot(x='freq', y='amp', label=l, c=colors[l], ax=ax)
70
+
71
+ #plt.legend(file.split(os.sep)[-3]) *日付ファイルのラベル表記
72
+
73
+ ax.grid(True)
74
+
75
+ plt.ylim([0,250])
48
76
 
49
77
  plt.tight_layout()
50
78
 
51
79
  plt.show()
80
+
81
+
82
+
83
+ GraphSortOverlap()
52
84
 
53
85
  ```
54
86
 
@@ -59,7 +91,3 @@
59
91
  こちらが複数のデータで正常の出力です。
60
92
 
61
93
  ![イメージ説明](87e4fa01627eafcb4d6cffa80b0aa84a.png)
62
-
63
- こちらが問題の上記のデータをまとめたものです。
64
-
65
- ![イメージ説明](0034544c8fcc66ecf134a2f4472bb719.png)

2

修正

2017/11/08 06:12

投稿

bkts94441
bkts94441

スコア18

test CHANGED
@@ -1 +1 @@
1
- CSVファイルを結合してグラフ描画について
1
+ python:jupyter notebookにてCSVファイルを結合してグラフ描画について
test CHANGED
@@ -1,12 +1,12 @@
1
1
  #目的
2
2
 
3
- 読み込んだ複数のCSVファイルを1つのグラフにまとめて描画したい。
3
+ python jupyternotebookにて、読み込んだ複数のCSVファイルを1つのグラフにまとめて描画したいです
4
4
 
5
5
 
6
6
 
7
7
  #問題点
8
8
 
9
- 下記のプログラムで出力するとグラフの値の数値が異常な数値になります。また、グラフの線の色が一色になり大変見にくいです。
9
+ 下記のプログラムで出力するとグラフの値の数値が異常な数値になります。また、グラフの線の色が一色になり大変見づらいです。
10
10
 
11
11
 
12
12
 

1

画像追加

2017/11/07 23:56

投稿

bkts94441
bkts94441

スコア18

test CHANGED
File without changes
test CHANGED
@@ -52,14 +52,14 @@
52
52
 
53
53
  ```
54
54
 
55
- すみません実行結果の画像は、また後ほど添付します
56
-
57
55
 
58
56
 
59
57
  #実行結果
60
58
 
61
- こちらが複数のデータですが正常の出力です。
59
+ こちらが複数のデータで正常の出力です。
62
60
 
63
-
61
+ ![イメージ説明](87e4fa01627eafcb4d6cffa80b0aa84a.png)
64
62
 
65
63
  こちらが問題の上記のデータをまとめたものです。
64
+
65
+ ![イメージ説明](0034544c8fcc66ecf134a2f4472bb719.png)