如何在gnuplot中设置灵活的xrange

时间:2018-02-20 01:55:47

标签: linux gnuplot

我一直在使用GNUplot使用重读功能在.dat文件中提供数据的实时更改。数据在xdirection中不断变化,如time参数。如果我使用set autoscale x,则最大x继续增加以适应更改。但是,我不希望图表的比例发生变化,也希望最小的x也能移动。

总而言之,我们是否有办法让xrange在区间内发生变化,如

if (x>5000) set xrange[(x-4000):(x+1000)]; else set autoscale x

我不知道如何将我的最后一个条目作为x输入。

为了使这个查询更具普遍性,一个人可能会遇到的熟悉问题。在无限时间序列上绘制正弦曲线,使您的绘图像心电图一样更新。

1 个答案:

答案 0 :(得分:0)

您可以尝试在实际绘图之前调用的stats命令。在下面的示例中,通过添加1000的统一偏移量来模拟数据文件中的更改。

#use exists to initialize variables on first use
offset = exists("offset")?offset+1000:0
it = exists("it")?it+1:1

#sample data
$data <<EOD
1000 1
2000 2
3000 3
4000 4
6000 6
EOD

#enable autoscale so that stat processes the whole file on reread
set xr [*:*]
stat $data u ($1 + offset):2 nooutput

#adjust scale for the subsequent plot below
if(STATS_max_x > 5000){
    set xr [STATS_max_x-4000:STATS_max_x+1000];
}else{
    set xr [*:*]
}

plot $data u ($1 + offset):2 w l

if(it >= 10) exit

pause 1
reread
相关问题