2017-02-24 228 views
1

我有數據繪製的結構是這樣的文件:如何從實際值在x軸偏移值軸原點

(timestamp MegaBytes) 
1487936469 0.003617 
1487936470 0.081604 
1487936471 0.244869 
1487936472 0.322519 
1487936473 0.242145 
1487936474 0.34596 
1487936475 0.385525 
1487936476 0.324402 
1487936477 0.154996 
1487936478 0.24336 
1487936479 0.38952 
1487936480 0.46152 
... 

using 1:2 with lines lw 3 
set xlabel "seconds"; set ylabel "MB" 
set format x '%.0f' 

enter image description here

繪圖情節是好的,但X軸(時間)不好看:是否有一個gnuplot命令,讓我從x範圍轉移[1487936469,last time stamp ]到[0,last value],以便x軸值將從0開始,而不是從1487936469開始?

回答

1

我覺得愚蠢到高五自己,但這裏是我如何解決了這個:

gnuplot> set grid 
gnuplot> set xlabel "seconds" 
gnuplot> set ylabel "MB" 

我的文件具有.log擴展名:創建文件的列表記錄。

gnuplot> list = system('ls *.log') 

「U」:使用 「WL」:用線, 「LW」:線寬

gnuplot> plot for [file in list] file u 1:2 w l lw 3 title file 

該地塊後,特殊變量已設置,檢查他們:

gnuplot> show variables all 
    ... 
    GPVAL_DATA_X_MIN = 1487936460.0 <- this is what I wanted 
    ... 

我將減去GPVAL_DATA_X_MIN將所有值在x軸:它存儲在一個變量和重製($1是第一列中,一個帶有時間戳):

gnuplot> MIN=GPVAL_DATA_X_MIN 
gnuplot> plot for [file in list] file u ($1-MIN):2 w l lw 3 title file 

enter image description here

好多了! 積分爲this questionthis question