如何使用gnuplot从单个数据文件制作多个点(行星)的动画. [英] How to animate multiple points (planets) using gnuplot, from a single data file.
问题描述
我正在尝试在稳定的Lagrange点L5上制作木星,太阳和小行星的动画,这些动画是它们绕其质心运动的.我想使用gnuplot制作动画.
I'm trying to make an animation of Jupiter, the sun and an asteroid at the stable Lagrange point L5 as they orbit around their center of mass. I want to do this animation using gnuplot.
我编写了一个程序,可以在t/AU时间找到他们的位置.我得到的数据在下面,具有列,时间,x位置,y位置,并且具有行,行星,太阳,小行星.我看过其他在gnuplot中制作动画的解决方案,但它们似乎对我不起作用.请帮助我了解我需要在gnuplot命令行中键入什么以获取此数据的动画.
I have written a programme which finds their positions at time t/AU. The data I get is below, has columns, time, x position, y position, and has rows, planet, sun, asteroid. I have looked at other solutions to animating in gnuplot but they do not seem to work for me. Please help me understand what I need to type into the gnuplot command line to get an animation of this data please.
谢谢.
0 0 5.19481
0 0 -0.00519481
0 4.50634 2.6
0.01 0.0275397 5.19473
0.01 -2.75397e-05 -0.00519473
0.01 4.52006 2.57607
0.02 0.0550786 5.19451
0.02 -5.50786e-05 -0.00519451
0.02 4.53365 2.55208
0.03 0.082616 5.19415
0.03 -8.2616e-05 -0.00519415
0.03 4.54712 2.52801
0.04 0.110151 5.19364
0.04 -0.000110151 -0.00519364
0.04 4.56046 2.50386
0.05 0.137683 5.19298
0.05 -0.000137683 -0.00519298
0.05 4.57367 2.47965
0.06 0.165211 5.19218
0.06 -0.000165211 -0.00519218
0.06 4.58675 2.45537
etc...
推荐答案
这只是草稿:
stats 'test.txt' u 2:3
set xr [STATS_min_x:STATS_max_x]
set yr [STATS_min_y:STATS_max_y]
do for [i=0:STATS_blocks-1] {
plot 'test.txt' index i u 2:3 w p pt 7 title sprintf("time: %f",i*0.01)
pause 1
}
您可以直接创建动画gif:
you can directly create an animated gif:
stats 'test.txt' u 2:3
set xr [STATS_min_x:STATS_max_x]
set yr [STATS_min_y:STATS_max_y]
set term gif animate
set output 'test.gif'
do for [i=0:STATS_blocks-1] {
plot 'test.txt' index i u 2:3 w p pt 7 title sprintf("time: %f",i*0.01)
}
现在这是非常基本的,但是可以调整以制作出真正高质量的图像.
Now this is quite basic, but can be tuned to make really high quality images.
这篇关于如何使用gnuplot从单个数据文件制作多个点(行星)的动画.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!