Create a gif in Gnuplot from a single file

南楼画角 提交于 2020-01-06 15:59:09

问题


I have a long file like the following (I am just writing a sample)

0.0 0.00209627946771 6483.0 3092622.0 1100
0.1 0.00253798848144 78.0 30733.0 1100
0.2 0.0174927113703 6.0 343.0 1100
0.3 0.0 0.0 35.0 1100
0.4 0.1 1.0 10.0 1100
0.5 0.0 0.0 4.0 1100
0.9 0.0 0.0 1.0 1100
1.0 0.0 0.0 2.0 1100
0.0 0.00292927058349 9057.0 3091896.0 2100
0.1 0.00299136583044 88.0 29418.0 2100
0.2 0.00743889479277 14.0 1882.0 2100
0.3 0.00578034682081 2.0 346.0 2100
0.4 0.0172413793103 2.0 116.0 2100
0.5 0.030303030303 1.0 33.0 2100
0.6 0.0 0.0 11.0 2100
0.7 0.0 0.0 10.0 2100
0.8 0.0 0.0 11.0 2100
0.9 0.181818181818 2.0 11.0 2100
1.0 0.0 0.0 16.0 2100
0.0 0.00318549549582 9845.0 3090571.0 3100
0.1 0.00273270708796 80.0 29275.0 3100
0.2 0.00489168413697 14.0 2862.0 3100
0.3 0.00810372771475 5.0 617.0 3100
0.4 0.010101010101 2.0 198.0 3100

The data I am interested to plot are the first and second column. In the 5th column there is the time of my simulation (it is the information related to the different timestamp).

Tacking inspiration from Creating a gif with gnuplot: Gif doesn't play I would like to write something like

set terminal gif size 1000,800 animate delay 6
set output 'try.gif'

set xrange [0:1]
set yrange [0:1]

do for [i=100:40200:100] {
 ....
}

but I have no idea to how indicate to gnuplot that the i-th block of data is given by the last column. Any suggestions?


回答1:


It seems that the timestamps are equidistant. Then you can try something like the following:

set terminal gif size 1000, 800 animate delay 100
set output 'try.gif'

# Viewing the 3D plot from top imitates a 2D plot.
set view map

set xlabel "x"
set ylabel "y"

do for [i=1100:3100:1000] {
  # Only points at time "i" are plotted.
  set zrange [i-1:i+1]
  set title "Time: ".i
  splot "data.dat" using 1:2:5 w lp
} 

Tested with Gnuplot 4.6 on Debian Linux. I did not care about performance reading the whole file again and again.

Running the script generates this



来源:https://stackoverflow.com/questions/40026393/create-a-gif-in-gnuplot-from-a-single-file

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