Created
March 31, 2016 06:25
-
-
Save u1and0/b27fdb356379d3204cebcb35dd9cd34c to your computer and use it in GitHub Desktop.
gnuplotでcsvの1行目(見出し行)をプロットのタイトルにする ref: http://qiita.com/u1and0/items/9ebba429004995efd4cd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1列目 2列目 3列目 4列目 n列目 | |
1行目 横軸見出し 見出し1 見出し2 見出し3... 見出しn... | |
2行目 横軸1 値11 値21 値31... 値n1 | |
3行目 横軸2 値12 値22 値32... 値n2 | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file='test.csv' #ファイル名指定 | |
se g #グリッドon | |
se xdata time #横軸は時間データだよ | |
se timefmt "%Y-%m-%d %H:%M:%S" #読み込む時間の形式 | |
se format x "%m/%d\n%H:%M" #x軸の表示方式 | |
se datafile separator "," #データ区切りを空白からコンマにする | |
p file u 1:2 w l #fileの1列目に対して2列目をプロット |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file='test.csv' | |
se g | |
se xdata time | |
se timefmt "%Y-%m-%d %H:%M:%S" | |
se format x "%m/%d\n%H:%M" | |
se datafile separator "," | |
lastrow=system(sprintf('awk -F, "NR==1{print NF}" %s',file)) #最後の列はawkの組み込み変数NFで読み込んで変数lastrowに入れる | |
p for[i=2:lastrow] file u 1:i w l #fileの1列目に対してi列目をプロット | |
#iは2からlastrowまで変化 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file='test.csv' | |
se g | |
se xdata time | |
se timefmt "%Y-%m-%d %H:%M:%S" | |
se format x "%m/%d\n%H:%M" | |
se datafile separator "," | |
lastrow=system(sprintf('awk -F, "NR==1{print NF}" %s',file)) | |
p for[i=2:lastrow] file u 1:i w l title system(sprintf('awk -F, "NR==1{print $%d}" %s',i,file)) #1行目の2列目~最後の列の文字列をtitleにする |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DateTime | midashi1 | midashi2 | midashi3 | midashi4 | midashi5 | |
---|---|---|---|---|---|---|
2015-12-01 00:03:00 | 5 | 8 | 10 | 41 | 39 | |
2015-12-01 00:08:00 | 4 | 7 | 9 | 35 | 58 | |
2015-12-01 00:13:00 | 5 | 5 | 6 | 36 | 60 | |
2015-12-01 00:18:00 | 4 | 7 | 9 | 36 | 59 | |
2015-12-01 00:23:00 | 4 | 7 | 7 | 59 | 59 | |
2015-12-01 00:28:00 | 4 | 5 | 7 | 36 | 60 | |
2015-12-01 00:33:00 | 3 | 8 | 9 | 36 | 59 | |
2015-12-01 00:38:00 | 4 | 7 | 10 | 36 | 59 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment