Simple C++ interface for Gnuplot with stream ability like std::cout and so on.
Small but it supports the full functionality of Gnuplot.
For Linux only! Sorry.
Example:
#include<gnuplotstream.hpp>usingnamespacestd;usingnamespacegpstr;// Namespace for Gnu-Plot-STReamintmain( void )
{
cout << "Minimal test-program plotting the function si(x)" << endl;
try
{
PlotStream plot( "--persist" );
plot << "plot sin(x)/x" << endl;
}
catch( exception& e )
{
cerr << e.what() << endl;
returnEXIT_FAILURE;
}
returnEXIT_SUCCESS;
}Result:
If PlotStream has to invoke Gnuplot with additional command line options, then these options are the first parameter of the constructor of PlotStream.
Example:
PlotStream plot( "-noraise --persist" );Alternatively you can define the macro GPSTR_DEFAULT_OPTIONS in your makefile.
By default the class PlotStream expect the executable of Gnuplot in /usr/bin/gnuplot.
If Gnuplot has been installed in a other directory,
then the executable file has to be the second parameter of the Constructor:
PlotStream plot( GPSTR_DEFAULT_OPTIONS, "/path/to/my/gnuplot" );or:
PlotStream plot( "-noraise --persist", "/path/to/my/gnuplot" );Alternatively you can define the macro GPSTR_DEFAULT_GNUPLOT_EXE in your makefile which will overwrite the default.
For detailed information about Gnuplot look in to the PDF documentation of Gnuplot.
Or visit the homepage of Gnuplot.
