GNUPlot - 2D MPEG data

I have a bunch of dots in the xy column which I made using a bit of fortran code. Some of it looks like this:

   1.000          0.000
   0.996          0.063
   0.988          0.125
   0.976          0.187
   0.961          0.249
   0.941          0.309
   0.917          0.368
   0.890          0.426
   0.859          0.481
   0.825          0.535
   0.787          0.587
   0.746          0.636
   0.702          0.682

      

and so far I can build it all in one image.

But what I need to do is plot the points, one at a time, like a movie. I would rather not do GIF as I need a time slider. When it moves, I need lines to connect the points.

However, all tutorials I have found that include MPEG lay down one DAT file at a time and render JPEGs in the movie. Like this one, Make a movie with data files using gnuplot , but I don't have enough resources for that.

Alternatively I tried the following: Gnuplot - plot position (xyz) and time data in a specific space (like a field) with a pause and then convert that to MPEG, but I can't get them to work. I am getting full graph in all frames and only animation n = #.

I was able to get an animation of "plot f (x, t)".

(edit: I don't have any code to animate the dots.)

+1


source to share


1 answer


To animate one point at a time, you can do it like this:

# calculate the number of points
stats 'file.txt' using 1:2 nooutput

# if you want to have a fixed range for all plots
set xrange [STATS_min_x:STATS_max_x]
set yrange [STATS_min_y:STATS_max_y]

set terminal pngcairo size 800,400
outtmpl = 'output%07d.png'

do for [i=0:STATS_records-1] {
    set output sprintf(outtmpl, i)
    plot 'file.txt' every ::::i with lines title sprintf('n = %d', i)
}
set output

      

and finally use something like



ffmpeg -i pic%07d.png movie.mpeg

      

to convert to movie.

Note that with plot

you must use every ::::i

(four in total :

) to limit the number of points plotted. The question you linked, Gnuplot - plot position (xyz) and time data in a specific space (like a field) with a pause , should use five :

to iterate over blocks of data, just like for 3D plots with splot

.

+2


source







All Articles