1
votes

I have a bunch of points in an x-y column, which I made using a bit of fortran code. Part 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 plot it all in one image.

But what I need to do is to plot the points, one at a time, as a movie. I'd rather not do GIF, as I need the time slider. As it moves, I need to have lines connect the dots.

However, all the tutorials I've found that involve MPEGs are plotting it one DAT file at a time, and making the JPEGs into the film. Like this one, Make movie with data files using gnuplot, but I don't have enough resources for that.

Alternatively, I tried to follow this: Gnuplot - plotting position(xyz) vs time data inside a specified space (eg a box) with a pause and then convert it to MPEG, but I can't get their code to work. I get the full plot in all frames, and only the n=# part is animating.

I was able to get a "plot f(x, t)" animated, though.

(edit: i have no code to animate the points. really)

1

1 Answers

2
votes

To animate one point at a time, you can do it as follows:

# 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 a movie.

Note, that with plot you must use every ::::i (only four :) to limit the number of plotted points. The question you linked, Gnuplot - plotting position(xyz) vs time data inside a specified space (eg a box) with a pause, must use five : to iterate over data blocks, like the are used for 3D-plots with splot.