Gnuplot:制作用矩阵生成的地图的 gif?

Gnuplot: Making a gif of a map generated with matrix?

我生成了一个包含 100 个矩阵 15x15 的 .dat 文件,现在我想创建一个 gif 来显示从第一个矩阵到最后一个矩阵的演变。它们都是带有 1 或 -1 的矩阵,所以如果我想表示初始矩阵,我可以将其复制并粘贴到另一个文件中,然后将其放入 gnuplot:

plot 'firstmatrix.dat' matrix with image

It represents the 1, -1 matrix with yellow and black.

要创建 gif,我尝试在 gnuplot 中执行此操作:

set terminal gif animate delay 20
set output 'evolution.gif'
set xrange [0:15]
set yrange [0:15]
N=15
nframes=5
do for [i=1:int(nframes)] {
  plot 'evolution.dat' every ::(i-1)*N+1::i*N matrix with image
}

我打算从文件的第一行读到第15行,然后从第16行读到第30行等等。

为了看得更清楚,我只放了 5 帧,我得到 gif 显示第一帧中的第一个矩阵,仅此而已,只有白色帧。

错误信息是四次次:

warning: Skipping data file with no valid points

所以第一帧的数据,第一个矩阵,处理得很好,但其余的没有。所以这是我的问题,我不知道为什么它处理第一个就没有了。

提前致谢。

It shows only the first matrix in the first frame

你已经很接近了。但我也花了一些迭代和测试...... 显然,从矩阵中切出一个行块需要 every :::rowFirst::rowLast(注意开头的 3 个冒号)。然后 gnuplot 显然将整个矩阵的行索引作为 y 坐标。因为你想让它“在彼此之上”,所以你需要模运算符 %(检查 help operators binary)。如果您的矩阵由一两个空行分隔,可能会更容易一些。

代码:

### animated matrix data
reset session

### create some random data
set print $Data
    do for [n=1:20] {
        do for [y=1:15] {
            Line = ''
            do for [x=1:15] {
                Line=Line.sprintf("% 3g",int(rand(0)*2)*2-1)
            }
            print Line
        }
    }
set print

set terminal gif animate delay 30
set output "tbMatrixAnimated.gif"
unset key 
N=15

do for [i=1:20] {
    plot $Data u 1:(int()%N):3 matrix every :::N*(i-1)::N*i-1 with image 
}
set output
### end of code

结果:(只有20个矩阵)