2014-09-05 32 views
0

我有一個看起來像這樣的文件:情節從晚上11點到早上9點的時間數據,可以追溯到

[email protected] asc-47$ head -n 2 imp 
23:22:37 23.3769 240.800 581.300  1.000  1.000 -2.839 -0.360  5.114  2.076 
23:23:07 23.3853 240.700 580.300  1.000  1.000 -2.838 -0.358  5.114  2.079 
[email protected] asc-47$ tail -n 2 imp 
09:22:23 9.3731 257.300 636.900  1.000  1.000 -2.867 -0.358  5.103  2.082 
09:22:53 9.3814 257.200 635.800  1.000  1.000 -2.867 -0.358  5.104  2.082 

我想繪製列3列VS 1.

我gnuplot的文件看起來像這樣:

#!/bin/gnuplot 
# 
set terminal svg size 1400,1048 enhanced fname 'Verdana' fsize 12 
set output 'curr-imp.svg' 
unset key 
set xlabel 'Tiempo (h)' 
set ylabel 'Corriente (mA)' 
set xdata time 
set timefmt "%H:%M:%S" 
set format x "%H" 
set style line 1 lc rgb '#000000' pt 6 ps 1 lt 1 lw 2 # --- black with empty circles 
set style line 11 lc rgb '#808080' lt 1 
set border 3 back ls 11 
set tics nomirror 
set style line 12 lc rgb '#808080' lt 0 lw 1 
set grid back ls 12 
plot 'imp' u 1:3 ls 1 w lp 

這給了我幾乎所需的輸出。 current vs time

問題是,線路回來了,因爲時間從晚上23點到09點。我在想,也許我應該有時間和日期。或者有另一種方法來解決這個問題?感謝很多您的時間

+3

對於相同的問題,請參閱[python gnuplot讀取csv文件以讀取順序或行順序繪製x軸的時間](http://stackoverflow.com/q/25308739/2604213)。我正在投票重複。我的建議是,雖然,如果你可以控制你的數據輸出,寫入時間戳:) – Christoph 2014-09-05 06:54:17

回答

0

只是爲了清楚起見,我會告訴我如何在最後做的事情。 (提供的鏈接是不完全的我來說,因爲我有在不同的文件不同天的數據。) 首先,添加DATE1到file1和date2與VIM(:%s/^/27-06-14/g:%s/^/28-06-14/g墨西哥到file2我們寫一天,爲期一個月年)。

[email protected] asc-47$ head -n 1 imp-27 
27-06-14 23:22:37 23.3769 240.800 581.300  1.000  1.000 -2.839 -0.360  5.114  2.076 
[email protected] asc-47$ tail -n 1 imp-28 
28-06-14 09:22:53 9.3814 257.200 635.800  1.000  1.000 -2.867 -0.358  5.104  2.082 

然後,將file1和file2合併到cat中。 之後,只需改變線路:

set timefmt "%d-%m-%y %H:%M:%S" set format x "%H %p" .... plot 'imp' u 1:4 ls 1 w lp

和你做。 :) enter image description here

+1

嗯,你寫你的問題這是一個確切的重複,你有沒有提到你有每天的一個數據文件。有了gnuplot,你還可以將這些信息作爲'plot' Christoph 2014-09-09 06:17:14

相關問題