Reputation: 6860
I am trying to implement Gnuplot on C++ to create a heat map. Once I run the following code, it opens a new gnu plot window with the plot on it. Can't I just write the graph as image file instead opening it on new window ?
Code:
Gnuplot gp;
gp << "unset key\n";
gp << "set pm3d\n";
// gp << "set hidden3d\n";
gp << "set view map\n";
gp << "set xrange [ 0 : 10 ] \n";
gp << "set yrange [ 0 : 10 ] \n";
gp << "splot '-'\n";
gp.send2d(frame);
Upvotes: 0
Views: 2112
Reputation: 1
Add the following lines to your script :
gp << "set terminal png\n";
gp << "set output 'my_file.png'\n";
There are other formats available, you can see this page to get more informations.
Upvotes: 0
Reputation: 1699
Just add output. Below code should work for you:
Gnuplot gp;
gp << "unset key\n";
gp << "set pm3d\n";
// gp << "set hidden3d\n";
gp << "set view map\n";
gp << "set xrange [ 0 : 10 ] \n";
gp << "set yrange [ 0 : 10 ] \n";
gp << "set terminal png \n";
gp << "set output 'b.png' \n";
gp << "splot '-'\n";
gp.send2d(frame);
Upvotes: 1