gnuplot 动画多个数据文件在 do 循环后保持
gnuplot animation multiple data files hold on after do loop
我正在使用两个数据文件制作动画。
我需要在第一个 do 循环后“坚持”,然后为动画重新绘制第二个 do 循环。
看下面的例子:
set term gif size 400,400 animate delay 100 loop 0 optimize font 'Verdana,10' crop
set output "output.gif"
set yrange [0:4]
set xrange [0:5]
$data1 << EOD
2.24448 0.270645 1.00 1.00
3.24448 0.270645 0.500 1.20
1.24448 0.411645 0.600 1.60
EOD
$data2 << EOD
3.24448 2.50645 0.400 1.00
0.24448 2.30645 0.800 1.20
1.24448 2.50000 0.300 0.60
1.55448 2.21645 0.300 1.30
EOD
stats $data1 using 1:4 nooutput
n1 = int(STATS_records) - 1
stats $data2 using 1:4 nooutput
n2 = int(STATS_records) - 1
plot x
do for [i=0:n1] {
replot $data1 u 1:2:3:4 every ::0::i w vectors lw 1.5 lc rgb "red" notitle
}
do for [i=0:n2] {
replot $data2 u 1:2:3:4 every ::0::i w vectors lw 1.5 lc rgb "blue" notitle
}
set output
输出如下:红色向量是从 data1
创建的,蓝色向量是从 data2
创建的。
我想先为红色矢量制作动画并稍等,然后开始为蓝色矢量制作动画。就目前而言,当蓝色矢量出现时,红色矢量消失并重新出现。我只想简单地开始一个接一个地为红色矢量制作动画,然后是蓝色矢量。
如下图:红色矢量按计划出现,但是蓝色矢量一出现,红色矢量就消失了,然后开始动画,我只想按照顺序,先绘制红色矢量并按住,然后继续动画蓝色矢量。
我猜 replot
有一个特殊的行为...(但我不记得细节)。
因此,我会在没有 replot
的情况下执行以下操作。
代码:
### animated vectors
reset session
set term gif size 400,400 animate delay 100 optimize font 'Verdana,10' crop
set output "output.gif"
set yrange [0:4]
set xrange [0:5]
$data1 << EOD
2.24448 0.270645 1.00 1.00
3.24448 0.270645 0.500 1.20
1.24448 0.411645 0.600 1.60
EOD
$data2 << EOD
3.24448 2.50645 0.400 1.00
0.24448 2.30645 0.800 1.20
1.24448 2.50000 0.300 0.60
1.55448 2.21645 0.300 1.30
EOD
stats $data1 using 1:4 nooutput
n1 = int(STATS_records) - 1
stats $data2 using 1:4 nooutput
n2 = int(STATS_records) - 1
plot x
do for [i=0:n1] {
plot x, \
$data1 u 1:2:3:4 every ::0::i w vectors lw 1.5 lc rgb "red" notitle
}
do for [i=0:n2] {
plot x, \
for [j=0:n1] $data1 u 1:2:3:4 every ::0::j w vectors lw 1.5 lc rgb "red" notitle, \
$data2 u 1:2:3:4 every ::0::i w vectors lw 1.5 lc rgb "blue" notitle
}
set output
### end of code
结果:
添加:(合并3个或更多文件)
数据:
File1.dat
2.24448 0.270645 1.00 1.00
3.24448 0.270645 0.500 1.20
1.24448 0.411645 0.600 1.60
File2.dat
3.24448 2.50645 0.400 1.00
0.24448 2.30645 0.800 1.20
1.24448 2.50000 0.300 0.60
1.55448 2.21645 0.300 1.30
File3.dat
4.0 1.0 -1.0 1.0
1.0 2.0 0.5 0.7
4.0 3.0 -1.0 -0.5
1.0 3.0 0.5 -1.0
代码:
### animated vectors from several files
reset session
set term gif size 400,400 animate delay 100 optimize font 'Verdana,10' crop
set output "output.gif"
set yrange [0:4]
set xrange [0:5]
set table $Arrows
plot 'File1.dat' u 1:2:3:4:('0xff0000') w table
plot 'File2.dat' u 1:2:3:4:('0x0000ff') w table
plot 'File3.dat' u 1:2:3:4:('0x00ff00') w table
unset table
plot x
do for [i=1:|$Arrows|] {
plot x, \
$Arrows u 1:2:3:4:5 every ::0::i-1 w vec lw 1.5 lc rgb var notitle
}
set output
### end of code
结果:
我正在使用两个数据文件制作动画。
我需要在第一个 do 循环后“坚持”,然后为动画重新绘制第二个 do 循环。
看下面的例子:
set term gif size 400,400 animate delay 100 loop 0 optimize font 'Verdana,10' crop
set output "output.gif"
set yrange [0:4]
set xrange [0:5]
$data1 << EOD
2.24448 0.270645 1.00 1.00
3.24448 0.270645 0.500 1.20
1.24448 0.411645 0.600 1.60
EOD
$data2 << EOD
3.24448 2.50645 0.400 1.00
0.24448 2.30645 0.800 1.20
1.24448 2.50000 0.300 0.60
1.55448 2.21645 0.300 1.30
EOD
stats $data1 using 1:4 nooutput
n1 = int(STATS_records) - 1
stats $data2 using 1:4 nooutput
n2 = int(STATS_records) - 1
plot x
do for [i=0:n1] {
replot $data1 u 1:2:3:4 every ::0::i w vectors lw 1.5 lc rgb "red" notitle
}
do for [i=0:n2] {
replot $data2 u 1:2:3:4 every ::0::i w vectors lw 1.5 lc rgb "blue" notitle
}
set output
输出如下:红色向量是从 data1
创建的,蓝色向量是从 data2
创建的。
我想先为红色矢量制作动画并稍等,然后开始为蓝色矢量制作动画。就目前而言,当蓝色矢量出现时,红色矢量消失并重新出现。我只想简单地开始一个接一个地为红色矢量制作动画,然后是蓝色矢量。
如下图:红色矢量按计划出现,但是蓝色矢量一出现,红色矢量就消失了,然后开始动画,我只想按照顺序,先绘制红色矢量并按住,然后继续动画蓝色矢量。
我猜 replot
有一个特殊的行为...(但我不记得细节)。
因此,我会在没有 replot
的情况下执行以下操作。
代码:
### animated vectors
reset session
set term gif size 400,400 animate delay 100 optimize font 'Verdana,10' crop
set output "output.gif"
set yrange [0:4]
set xrange [0:5]
$data1 << EOD
2.24448 0.270645 1.00 1.00
3.24448 0.270645 0.500 1.20
1.24448 0.411645 0.600 1.60
EOD
$data2 << EOD
3.24448 2.50645 0.400 1.00
0.24448 2.30645 0.800 1.20
1.24448 2.50000 0.300 0.60
1.55448 2.21645 0.300 1.30
EOD
stats $data1 using 1:4 nooutput
n1 = int(STATS_records) - 1
stats $data2 using 1:4 nooutput
n2 = int(STATS_records) - 1
plot x
do for [i=0:n1] {
plot x, \
$data1 u 1:2:3:4 every ::0::i w vectors lw 1.5 lc rgb "red" notitle
}
do for [i=0:n2] {
plot x, \
for [j=0:n1] $data1 u 1:2:3:4 every ::0::j w vectors lw 1.5 lc rgb "red" notitle, \
$data2 u 1:2:3:4 every ::0::i w vectors lw 1.5 lc rgb "blue" notitle
}
set output
### end of code
结果:
添加:(合并3个或更多文件)
数据:
File1.dat
2.24448 0.270645 1.00 1.00
3.24448 0.270645 0.500 1.20
1.24448 0.411645 0.600 1.60
File2.dat
3.24448 2.50645 0.400 1.00
0.24448 2.30645 0.800 1.20
1.24448 2.50000 0.300 0.60
1.55448 2.21645 0.300 1.30
File3.dat
4.0 1.0 -1.0 1.0
1.0 2.0 0.5 0.7
4.0 3.0 -1.0 -0.5
1.0 3.0 0.5 -1.0
代码:
### animated vectors from several files
reset session
set term gif size 400,400 animate delay 100 optimize font 'Verdana,10' crop
set output "output.gif"
set yrange [0:4]
set xrange [0:5]
set table $Arrows
plot 'File1.dat' u 1:2:3:4:('0xff0000') w table
plot 'File2.dat' u 1:2:3:4:('0x0000ff') w table
plot 'File3.dat' u 1:2:3:4:('0x00ff00') w table
unset table
plot x
do for [i=1:|$Arrows|] {
plot x, \
$Arrows u 1:2:3:4:5 every ::0::i-1 w vec lw 1.5 lc rgb var notitle
}
set output
### end of code
结果: