Skip to content

Latest commit

 

History

History
119 lines (66 loc) · 4.53 KB

File metadata and controls

119 lines (66 loc) · 4.53 KB

 

 

 

 

 

 

gnuplot example 2 is a gnuplot example.

 

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

  • STL STL: GNU ISO C++ Library, version 4.6.3

 

 

 

 

 

Qt project file: CppGnuplotExample2.pro

 


TEMPLATE = app CONFIG += console CONFIG += qt SOURCES += main.cpp

 

 

 

 

 

main.cpp

 


#include <fstream> #include <string> #include <cstdlib> #include <QApplication> #include <QLabel> int main(int argc, char *argv[]) {   QApplication a(argc,argv);   #ifdef WIN32   const std::string exe = "C:\\Progra~1\\gnuplot\\bin\\gnuplot.exe";   #else   const std::string exe = "gnuplot";   #endif   const std::string cmd_filename = "test.txt";   const std::string pic_filename = "test.png";   {     std::ofstream f(cmd_filename.c_str());     f <<       "set terminal pngcairo\n"       "set output '" << pic_filename <<"'\n"       "set key inside left top vertical Right noreverse enhanced autotitles box linetype -1 linewidth 1.000\n"       "set samples 50, 50\n"       "plot [-10:10] sin(x),atan(x),cos(atan(x))";   }   const std::string cmd = exe + " " + cmd_filename;   std::system(cmd.c_str());   QLabel label;   label.setPixmap(QPixmap(pic_filename.c_str()));   label.show();   return a.exec(); }