0

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);

enter image description here

1

2 Answers 2

1

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);
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.