How to animate multiple points (planets) using gnuplot, from a single data file.

你说的曾经没有我的故事 提交于 2019-12-24 16:51:45

问题


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.

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.

Thank you.

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...

回答1:


This is just a draft:

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
}

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.



来源:https://stackoverflow.com/questions/36162214/how-to-animate-multiple-points-planets-using-gnuplot-from-a-single-data-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!