TipiWiki2

[ GnuPlot.2006-12-11-14-04 ]

edit | Recent Changes | Find Page | All Pages | Front Page |

GnuPlot und C++

http://alpine.suiri.tsukuba.ac.jp/~asanuma/gnuplot++/
ggf. braucht man (unter Linux) das dev-paket von Gnuplot (inkludieren der "gnuplotpp.h")

http://www.duke.edu/~hpgavin/gnuplot.html (Tutorial)
http://userpage.fu-berlin.de/~voelker/gnuplotkurs/gnuplotkurs.html (Grundkurs)

class GNUplot
{
public:
 GNUplot() throw(string);
 ~GNUplot();
 void operator ()(const string& command);
 // send any command to gnuplot
protected:
 FILE *gnuplotpipe;
};

GNUplot::GNUplot() throw(string)
{
 gnuplotpipe=popen("gnuplot","w");
 if (!gnuplotpipe) {
   throw("Gnuplot not found !");
 }
}

GNUplot::~GNUplot()
{
 fprintf(gnuplotpipe,"exit\n");
 pclose(gnuplotpipe);
}

void GNUplot::operator() (const string& command)
{
 fprintf(gnuplotpipe,"%s\n",command.c_str());
 fflush(gnuplotpipe);
 // flush is necessary, nothing gets plotted else
};

...

GNUplot plotter;
plotter("plot 'omni_00002_00001_00012.dat'");
cout << "Press 'q' + <enter> to quit" << endl;  
char a;
cin >> a;