#include <vector>
#include <cmath>
#include <boost/tuple/tuple.hpp>
#include "gnuplot-iostream.h"
int main()
{
float frame[4][4];
for (int n=0; n<4; n++)
{
for (int m=0; m<4; m++)
{
frame[n][m]=n+m;
}
}
Gnuplot gp;
gp << "unset key\n";
gp << "set pm3d\n";
gp << "set hidden3d\n";
gp << "set view map\n";
gp << "set xrange [ -0.500000 : 3.50000 ] \n";
gp << "set yrange [ -0.500000 : 3.50000 ] \n";
gp << "splot '-'\n";
gp.send2d(frame);
gp.flush();
}
This generates me an image:
The problem is, that element "frame[0][0]" should be black in this color palette. And I suppose it is black, but the area between four points is colored in blue (color for average value of these four points). What I want, that I could generate an image like this: link to gnuplot heatmap example. It actually colors a matrix element, not the area between four elements. So how do I do that using C++ and an iostream pipe? I can print data to a file and then plot from that file, but this can be slow... Any ideas?