用动画绘制gnuplot中的2D数组

时间:2014-05-20 14:27:17

标签: c++ arrays linux gnuplot

我无法使用颜色映射绘制2D数组。下面的代码确实绘制了矩阵,但是在5秒延迟后出现了图表。它的接缝出现在程序的最后,因此动画是不可能的。带有动画的gnuplot-iostream包中的一个例子效果很好(一个情节在延迟之前出现并刷新,而不是在程序结束时)。

#include "gnuplot-iostream.h"

double matrica[80][120];

void recalculate (int koef)
{
    for (int a=0; a<80; a++)
    {
        for (int b=0; b<120; b++)
        {
            matrica[a][b] = a*b*(sin(koef));
        }
    }
}
int main()
{
    Gnuplot gp;
    gp << "set xrange [0:110]\nset yrange [0:70]\n";
    gp << "set pm3d\n";
    gp << "set hidden3d\n";
    gp << "set view map\n";
    recalculate(1);
    gp << "splot '-' matrix" <<"\n";
    gp.send1d(matrica);
    gp.flush();
    sleep(5);
}

0 个答案:

没有答案