Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/145.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 为什么我的热图是空的(白色)?_C++_Gnuplot_Gnuplot Iostream - Fatal编程技术网

C++ 为什么我的热图是空的(白色)?

C++ 为什么我的热图是空的(白色)?,c++,gnuplot,gnuplot-iostream,C++,Gnuplot,Gnuplot Iostream,我想画一张热图,我有一个2d阵列,我遵循这个答案: 除了在C++中使用GnUpTrand,我删除了“非一致”,因为第一行和列是正则值,而不是蜱。 Gnuplot gp; gp << "set autoscale xfix \n"; gp << "set autoscale yfix \n"; gp << "set autoscale cbfix \n"; gp << "plot '-' matrix with image notitle\n"; g

我想画一张热图,我有一个2d阵列,我遵循这个答案: 除了在C++中使用GnUpTrand,我删除了“非一致”,因为第一行和列是正则值,而不是蜱。
Gnuplot gp;
gp << "set autoscale xfix \n";
gp << "set autoscale yfix \n";
gp << "set autoscale cbfix \n";
gp << "plot '-' matrix with image notitle\n";
gp.send2d(pmat);
gp.flush();

因此,问题必须来自于我对C++ API

的使用。如果<>代码> GnTrof IoSturiS/<代码>没有对矩阵格式的2-D数据的内置支持,那么您可以很容易地在代码中实现这一点。差不多

gp << "plot '-' matrix with image notitle\n";
for (int i = 0; i < 50; ++i) {
    for (int j = 0; j < 50; ++j)
        gp << pmat[i][j] << "\t";
    gp << "\n";
}
gp.flush();

gp我不熟悉
gnuplotiostream
,但据我所知,
send2d
似乎不以矩阵形式发送数组数据,而是以一维列表的形式发送,其中的空格表示新行或新列。如果您用
gp替换plot命令会发生什么谢谢您的评论,它确实适用于该行,但是它绘制了一个三维图形,而我想要的是一个热图(在(x,y)处的颜色表示pmat[x][y])。您是否只是尝试删除
矩阵
关键字,即仅使用
plot“-”和图像
gp << "plot '-' matrix with image notitle\n";
for (int i = 0; i < 50; ++i) {
    for (int j = 0; j < 50; ++j)
        gp << pmat[i][j] << "\t";
    gp << "\n";
}
gp.flush();