C++ 为什么我的热图是空的(白色)?
我想画一张热图,我有一个2d阵列,我遵循这个答案: 除了在C++中使用GnUpTrand,我删除了“非一致”,因为第一行和列是正则值,而不是蜱。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
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();