如何随着图的变化更新图上的数值

时间:2019-04-21 19:28:57

标签: gnuplot

我正在尝试在实心圆图上一次添加一次时添加时间信息。因此,它看起来像是一个在实地上四处移动的实心圆的电影。

我尝试了如下所示的简单Gnuplot代码和数据集。 问题是要从图上第一列的“?。???”获取更新的时间信息。是随着圆圈的移动。

set terminal aqua 1
set size ratio -1
set style fill solid 
set ylabel "Y" 
set xlabel "X"
set label "Time=?.??? sec" at screen 0.7,0.8
do for [t=0:5] {plot [-.25:1.5] [-.25:1.5] "d.dat" every ::t::t u 1:2:(0.02) t "" w circles; pause 1.0}

,数据集是:

# Time    x      y
 0.2000 0.0000 0.0000
 0.4000 0.2618 0.2588
 0.6000 0.5236 0.5000
 0.8000 0.7854 0.7071
 1.0000 1.0472 0.8660
 1.2000 1.3090 0.9659

我不知道如何将第一列中的时间信息用于plot命令。

1 个答案:

答案 0 :(得分:1)

您可以使用绘图样式with labels,并从数据文件/数据块的某个坐标(此处为(0):(1.4))处绘制时间。

代码:

### time as label
reset session

$Data <<EOD
# Time    x      y
 0.2000 0.0000 0.0000
 0.4000 0.2618 0.2588
 0.6000 0.5236 0.5000
 0.8000 0.7854 0.7071
 1.0000 1.0472 0.8660
 1.2000 1.3090 0.9659
EOD

set key left
set xrange [-.25:1.5]
set yrange [-.25:1.5]
set style fill solid 

do for [t=0:5] {
    plot $Data every ::t::t u 2:3:(0.02) w circles notitle, \
    '' u (0):(1.4):(sprintf("Time: %g",$1)) every ::t::t with labels notitle
    pause 1.0
}
### end of code

结果:

enter image description here

相关问题