Discussion:
animation from data files
(too old to reply)
Shahid Maqbool
2022-11-02 05:45:52 UTC
Permalink
Dear all,

I have data files in the order like:

data_100.dat
data_200.dat
data_300.dat
...
data_10000.dat

here 100, 200, 300, ..., 10000 are the time steps.

I can successfully plot surface plot for data file e.g., 'data_10.dat' with the command i.e.,

splot 'data_100.dat' matrix with pm3d notitle

Now, i want to make animation for my data files to see the
continuous evolution of the system.

I have gone throught the book 'Gnuplot in Action' and section 11.5 shows some animations, but it is not telling about loading different files. Also the online demos like

https://gnuplot.sourceforge.net/demo/animate2.html

are not very helpful in this case.

So my question is, which commands or keywords should i use to load the continuous files and display the animation on the console?

Thanks a lot.

Best regards,
Shahid
Olaf Schultz
2022-11-02 15:29:13 UTC
Permalink
Post by Shahid Maqbool
Dear all,
data_100.dat
data_200.dat
data_300.dat
...
data_10000.dat
here 100, 200, 300, ..., 10000 are the time steps.
I can successfully plot surface plot for data file e.g., 'data_10.dat' with the command i.e.,
splot 'data_100.dat' matrix with pm3d notitle
Now, i want to make animation for my data files to see the
continuous evolution of the system.
I have gone throught the book 'Gnuplot in Action' and section 11.5 shows some animations, but it is not telling about loading different files. Also the online demos like
https://gnuplot.sourceforge.net/demo/animate2.html
are not very helpful in this case.
So my question is, which commands or keywords should i use to load the continuous files and display the animation on the console?
Thanks a lot.
Best regards,
Shahid
Here something like that (for a temperature-profile in the soil):

set grid
set terminal gif animate delay 0.1
stats "reform4anim.csv" nooutput
set output "animated.gif"
set xrange [0:15]
set yrange [-200:10]
do for [i=1:int(STATS_blocks):4] {plot "reform4anim.csv" u 2:1 index
(i-1) with linespoints t "\@time","" u 2:1:3 index (i-1) w labels t
"","Bodensonde_Statistik_h.csv" u 3:1 t "max" lc "red","" u 5:1 t "min"
lc "blue","" u 4:1 t "avg" lc "black"}


HTH, Olaf
Karl Ratzsch
2022-11-05 19:09:38 UTC
Permalink
Something like this?

fname(n) = sprintf('data_%.f.dat',n)

n=100
while (n<=10000) {
plot fname(n)
n=n+100
}
Post by Shahid Maqbool
Dear all,
data_100.dat
data_200.dat
data_300.dat
...
data_10000.dat
here 100, 200, 300, ..., 10000 are the time steps.
I can successfully plot surface plot for data file e.g., 'data_10.dat' with the command i.e.,
splot 'data_100.dat' matrix with pm3d notitle
Now, i want to make animation for my data files to see the
continuous evolution of the system.
I have gone throught the book 'Gnuplot in Action' and section 11.5 shows some animations, but it is not telling about loading different files. Also the online demos like
https://gnuplot.sourceforge.net/demo/animate2.html
are not very helpful in this case.
So my question is, which commands or keywords should i use to load the continuous files and display the animation on the console?
Thanks a lot.
Best regards,
Shahid
Russell Kajouri
2022-11-07 09:53:11 UTC
Permalink
Hi

I think that there is no need to use %f, and you can put the name of the file and its definition into the loop, and then it works better!


n=100
while (n<=10000) {
fname = sprintf('data_%d.dat',n)
plot fname
n=n+100
}
Post by Karl Ratzsch
Something like this?
fname(n) = sprintf('data_%.f.dat',n)
n=100
while (n<=10000) {
plot fname(n)
n=n+100
}
Post by Shahid Maqbool
Dear all,
data_100.dat
data_200.dat
data_300.dat
...
data_10000.dat
here 100, 200, 300, ..., 10000 are the time steps.
I can successfully plot surface plot for data file e.g., 'data_10.dat' with the command i.e.,
splot 'data_100.dat' matrix with pm3d notitle
Now, i want to make animation for my data files to see the
continuous evolution of the system.
I have gone throught the book 'Gnuplot in Action' and section 11.5 shows some animations, but it is not telling about loading different files. Also the online demos like
https://gnuplot.sourceforge.net/demo/animate2.html
are not very helpful in this case.
So my question is, which commands or keywords should i use to load the continuous files and display the animation on the console?
Thanks a lot.
Best regards,
Shahid
Shahid Maqbool
2022-11-08 02:58:07 UTC
Permalink
Post by Russell Kajouri
Hi
I think that there is no need to use %f, and you can put the name of the file and its definition into the loop, and then it works better!
n=100
while (n<=10000) {
fname = sprintf('data_%d.dat',n)
plot fname
n=n+100
}
Post by Karl Ratzsch
Something like this?
fname(n) = sprintf('data_%.f.dat',n)
n=100
while (n<=10000) {
plot fname(n)
n=n+100
}
Hi all,

Following your suggestions i wrote it like that:

set grid
set terminal gif animate delay 0.1
fname(n) = sprintf('data_%d.dat',n)
n=100
while (n<=10000){
splot fname(n) matrix with pm3d notitle
n=n+100
}

or

set grid
set terminal gif animate delay 0.1

n=100
while (n<=10000){
fname = sprintf('data_%d.dat',n)
splot fname matrix with pm3d notitle
n=n+100
}


but i always get this error:

more> ;splot fname(n) matrix with pm3d notitle ;n=n+100;
^
cannot output binary data to wgnuplot text window

gnuplot>
Jörg Buchholz
2022-11-08 06:01:26 UTC
Permalink
Post by Shahid Maqbool
Post by Russell Kajouri
Hi
I think that there is no need to use %f, and you can put the name
of the file and its definition into the loop, and then it works
better!
n=100 while (n<=10000) { fname = sprintf('data_%d.dat',n) plot
fname n=n+100 }
Post by Karl Ratzsch
Something like this?
fname(n) = sprintf('data_%.f.dat',n)
n=100 while (n<=10000) { plot fname(n) n=n+100 }
Hi all,
set grid set terminal gif animate delay 0.1 fname(n) =
sprintf('data_%d.dat',n) n=100 while (n<=10000){ splot fname(n)
matrix with pm3d notitle n=n+100 }
or
set grid set terminal gif animate delay 0.1
You must specify a output file name.
set out 'filename.gif'
Post by Shahid Maqbool
n=100 while (n<=10000){ fname = sprintf('data_%d.dat',n) splot fname
matrix with pm3d notitle n=n+100 }
more> ;splot fname(n) matrix with pm3d notitle ;n=n+100; ^ cannot
output binary data to wgnuplot text window
gnuplot>
Loading...