来自数据文件的Gnuplot在动画的do for循环中分配 [英] Gnuplot from data file for assignment in do for loop for an animation

查看:60
本文介绍了来自数据文件的Gnuplot在动画的do for循环中分配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有一个像这样的数据文件:

Say I have a data file like so:

1.3 4.23
1.23 5.667
.
.
.

这些是我行的常量.我想将其制作成动画gif,但是在获取特定数据时遇到了麻烦.

These are the constants for my line. I want to make this into an animated gif but I'm having trouble getting particular data.

到目前为止,我在做

set terminal gif animate delay 50
set output 'test.gif'
stats 'temp.dat' nooutput
set xrange[-1:1]
set yrange[-1:1]
h(x) = a*x + b

这是我遇到麻烦的地方.我尝试了以下两种方法:

and here is where I'm having trouble. I tried these two approaches:

do for [i=1:int(STATS_records)]{
   plot h(x) u (a=$1):(b=$2) w l
}

和这个:

plot 'temp.dat', f(x) = ($1)*x + ($2)

都不起作用.帮助表示赞赏.

Neither is working. Help appreciated.

推荐答案

要从文件中提取参数,必须在每次迭代中调用stats,并仅选择every

In order to extract parameters from a file, you must call stats in every iteration and select only the i-th row with every

set terminal gif animate delay 50
set output 'test.gif'

set xrange[-10:10]
set yrange[-10:10]
h(x) = a*x + b

stats 'temp.dat' nooutput
N = int(STATS_records) - 1

do for [i=0:N] {
  stats 'temp.dat' every ::i::i nooutput
  a = STATS_min_x
  b = STATS_min_y
  plot h(x) with lines
}

这篇关于来自数据文件的Gnuplot在动画的do for循环中分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆