TipiWiki2

[ GnuPlot.2006-12-11-16-19 ]

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

Allg.

plot 'kurve1.dat', 'kurve2.dat'   # mehrere Kurven übereinander plotten
plot 'kurve.dat' w l              # with lines
set yrange[0:1]
set xrange[0:0.2]
set grid
replot

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 'data.dat'");
cout << "Press 'q' + <enter> to quit" << endl;  
char a;
cin >> a;