So, this time, I have a matrix called zvalue[10][10], and I would like to draw a pm3d map, with normal x-y grids, and with zvalue[i][j] to be the value of point (i,j).
In gnuplot, I just use:
set pm3d map
splot zvalue matrix using 1:2:3 with pm3d
And in C++ gnuplot pipes, I can use a function gp.file1d() to achieve this.
gp << "splot" << gp.file1d(matrix) << "matrix using 2:1:3" << "with pm3d\n"
But now, I am in C gnuplot pipe, of course I can write the matrix into a file called zvalue.txt, and use the following:
fprintf(gp, "splot \"zvalue.txt\" matrix using 1:2:3 with pm3d\n")
But is there other way? I tried @Christ's suggestion when I deal with normal splot with matrix, that is do something like:
int main(void)
{
FILE *gp = popen(GNUPLOT, "w");
fprintf(gp, "splot '-' matrix using 1:2:3\n");
int i, j;
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++)
fprintf(gp, "%d ", i*j);
fprintf(gp, "\n");
}
pclose(gp);
return 0;
}
But when it's pm3d, it does not work well. I also tried with splot point by point, which works well for nomal splot with matrix, but here with pm3d, nothing works.
