gnuplot 动画 2D 矢量场
gnuplot animation 2D vector fields
我正在尝试使用 gnuplot 为 2D 矢量制作动画。我想显示一行,即一次显示一个向量。
我的数据结构如下:他们x,y,u,v
2.24448 0.270645 1.00 1.00
3.24448 0.270645 0.500 1.20
我可以使用以下命令创建静态情节:
plot "datam.dat" using 1:2:3:4 with vectors filled head lw 3
这是输出:
这是我的问题:我想动画化并显示一行(即)一次显示一个 向量,如何使用 GIF 在 GNU plot 中完成此操作?
谢谢
动画 GIF 是使用 set terminal gif animate
创建的。检查 help gif
了解详情。
下面是一个简单的示例(使用 gnuplot 5.2 测试)。你必须为每一帧制作一个新的情节。因此,将您的绘图命令放入 do for
循环中。使用 every ::i::i
,您仅绘制第 i
行(检查 help every
)。如果您不知道数据文件的总行数,请执行 stats "YourFile.dat"
,变量 STATS_records
会告诉您这个数字。
代码:
### animated graph with vectors
reset session
set term gif size 300,300 animate delay 12 loop 0 optimize
set output "AnimateVectors.gif"
# create some dummy data
set angle degrees
N = 60
set samples N
set table $Data
plot [0:360] '+' u (cos()):(sin()):(sin()):(cos()) w table
unset table
set xrange[-2.5:2.5]
set yrange[-2.5:2.5]
do for [i=0:N-1] {
plot $Data u 1:2:3:4 every ::i::i w vectors lw 2 lc rgb "red" notitle
}
set output
### end of code
结果:
加法:
这将是 non-animated 版本,例如在 wxt
终端中。
代码:
### non-animated graph with vectors
reset session
set term wxt size 400,400
# create some dummy data
set angle degrees
N = 60
set samples N
set table $Data
plot [0:360] '+' u (cos()):(sin()):(sin()):(cos()) w table
unset table
set xrange[-2.5:2.5]
set yrange[-2.5:2.5]
plot $Data u 1:2:3:4 w vectors lw 1.5 lc rgb "red" notitle
### end of code
结果:
加法2:
你的意思是这样的吗? "semi" 动画箭头?顺便说一下,正如您所见,gif
和 wxt
终端中的箭头看起来完全不同。
代码:
### "semi"-animated graph with vectors
reset session
set term gif size 300,300 animate delay 12 loop 0 optimize
set output "AnimateVectorsSemi.gif"
# create some dummy data
set angle degrees
N = 60
set samples N
set table $Data
plot [0:360] '+' u (cos()):(sin()):(sin()):(cos()) w table
unset table
set xrange[-2.5:2.5]
set yrange[-2.5:2.5]
do for [i=0:N-1] {
plot $Data u 1:2:3:4 every ::0::i w vectors lw 1.5 lc rgb "red" notitle
}
set output
### end of code
结果:
我正在尝试使用 gnuplot 为 2D 矢量制作动画。我想显示一行,即一次显示一个向量。
我的数据结构如下:他们x,y,u,v
2.24448 0.270645 1.00 1.00
3.24448 0.270645 0.500 1.20
我可以使用以下命令创建静态情节:
plot "datam.dat" using 1:2:3:4 with vectors filled head lw 3
这是输出:
这是我的问题:我想动画化并显示一行(即)一次显示一个 向量,如何使用 GIF 在 GNU plot 中完成此操作?
谢谢
动画 GIF 是使用 set terminal gif animate
创建的。检查 help gif
了解详情。
下面是一个简单的示例(使用 gnuplot 5.2 测试)。你必须为每一帧制作一个新的情节。因此,将您的绘图命令放入 do for
循环中。使用 every ::i::i
,您仅绘制第 i
行(检查 help every
)。如果您不知道数据文件的总行数,请执行 stats "YourFile.dat"
,变量 STATS_records
会告诉您这个数字。
代码:
### animated graph with vectors
reset session
set term gif size 300,300 animate delay 12 loop 0 optimize
set output "AnimateVectors.gif"
# create some dummy data
set angle degrees
N = 60
set samples N
set table $Data
plot [0:360] '+' u (cos()):(sin()):(sin()):(cos()) w table
unset table
set xrange[-2.5:2.5]
set yrange[-2.5:2.5]
do for [i=0:N-1] {
plot $Data u 1:2:3:4 every ::i::i w vectors lw 2 lc rgb "red" notitle
}
set output
### end of code
结果:
加法:
这将是 non-animated 版本,例如在 wxt
终端中。
代码:
### non-animated graph with vectors
reset session
set term wxt size 400,400
# create some dummy data
set angle degrees
N = 60
set samples N
set table $Data
plot [0:360] '+' u (cos()):(sin()):(sin()):(cos()) w table
unset table
set xrange[-2.5:2.5]
set yrange[-2.5:2.5]
plot $Data u 1:2:3:4 w vectors lw 1.5 lc rgb "red" notitle
### end of code
结果:
加法2:
你的意思是这样的吗? "semi" 动画箭头?顺便说一下,正如您所见,gif
和 wxt
终端中的箭头看起来完全不同。
代码:
### "semi"-animated graph with vectors
reset session
set term gif size 300,300 animate delay 12 loop 0 optimize
set output "AnimateVectorsSemi.gif"
# create some dummy data
set angle degrees
N = 60
set samples N
set table $Data
plot [0:360] '+' u (cos()):(sin()):(sin()):(cos()) w table
unset table
set xrange[-2.5:2.5]
set yrange[-2.5:2.5]
do for [i=0:N-1] {
plot $Data u 1:2:3:4 every ::0::i w vectors lw 1.5 lc rgb "red" notitle
}
set output
### end of code
结果: