c++gnuplotgnuplot-iostream

Proper Way to Plot with GNUPlot? (C++ 14, VS 22)


I'm attempting to graph some data with the GNUPlot library in C++. I'm using Visual Studio 2022 with C++ 14. I also installed the boost libraries and am using the gnuplot-iostream.h file from dsthalke's GitHib repository.

As far as I understand, GNUPlot is different than MatPlotLib in the sense that it is a lower-level method of plotting data. As far as I understand, it consists of sending a series of commands via the << operator to a variable of type of Gnuplot.

I've been attempting to plot a few basic examples, from the GNUPlot documentation website and other examples.

Attempting to run Example 1 and 2 from the documentation website results in nothing happening, and the message pclose return error: No error.

Attempting to run any of the examples from this website also results in the same output.

That is, the following example code from the above website:

#include "gnuplot-iostream.h"

int main()
{
    Gnuplot plot;
    
    plot << "set dgrid3d 200,200,1";
    plot << "set pm3d";
    plot << "set palette";
    plot << "set palette color";
    plot << "set pm3d map";
    plot << "splot \"sin_cos_data\"";

    return 0;
}

Also results in nothing.

How does one graph data with GNUPlot in C++? Is there a different set of examples that I have not yet come accross, that would be better for explaining how to do it?

Thanks for reading my post, any guidance is appreciated.


Solution

  • Well that's embarrassing... Turns out I didn't actually install the GNUPlot library separately.

    Talk about rushing...