2017-02-24 89 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