0
votes

I want to know how to make a Gnuplot 2d animation using the gnuplot matrix non uniform format, with the first column being the time, the first row being the x axis ticks and the first number of the first row being the number of columns after the first one, an example of such a matrix is given by, imagine we have 2 time iterations and 2 space points. If the index goes from 0 to 1 then,such matrix would be like this

2     x[0] x[1]

t[0] f(0,0) f(0,1)

t[1] f(1,0) f(1,1)

How to make a 2d animation in gnuplot for f(t,x) for each time iteration?

Thanks

1

1 Answers

0
votes

it probably might be easier if your data looked the following way:

2x2    t[0]     t[1]
x[0]   f(0,0)   f(0,1)
x[1]   f(1,0)   f(1,1)

If your data already exists with columns x[..] and rows t[..] there is probably also a way to do it, but probably a bit more complicated. The following example will create some dummy data (writes it also into a file) and will plot it into an animated GIF. In gnuplot, also check help gif for more information. Change the code to your needs.

### create some animated graph
reset session

set term gif size 300,300 animate delay 10 loop 0 optimize
set output "Animate.gif"

# create some dummy data
m = 50
n = 50
set print $Data 
temp = sprintf("%gx%g\t",m,n)
do for [j=1:n] {
    temp = temp.sprintf("t[%g]",j)
    if (j<n) {temp = temp."\t"}
}
print temp
do for [i=1:m] {
    temp = ""
    do for [j=1:n] {
        temp = temp.sprintf("%g", sin(2*pi*j/real(n)+2*pi*i/real(m)))
        if (j<n) {temp = temp."\t"}
    }
    temp = sprintf("x[%g]\t",i).temp
    print temp
}
set print "Animate.dat"
print $Data 
set print
# dummy data finished

FILE = "Animate.dat"
stats FILE u 0 nooutput
set yrange[-1:1]
set xtics 10
set grid xtics, ytics
do for [i=2:STATS_columns] {
   plot FILE u 0:i w lp lt 7 lc rgb "red" title columnhead(i)
}
set output
### end code

enter image description here