Gnuplot保存了许多图像

时间:2014-03-19 12:10:07

标签: c++ c png gnuplot

我想将gnuplot操作的结果写入png文件并且这个成功,但是我需要生成大约100个png文件,这里我遇到了问题,因为我收到错误"临时文件的最大数量gnuplot是27"。当我使用方法remove_tmpfiles()时,所有图像都正确生成,但其中大约20-30个不可打开。当我仅保存推荐的27张图像时,不会出现此错误。

Gnuplot::set_GNUPlotPath( GNUPLOT_PATH );
Gnuplot *main_plot = new Gnuplot;    
main_plot->cmd("set terminal pngcairo\n");
for(int j=0; j<100;j++)
{   
 rysuj_wagi(j, main_plot);  
 if(j%25 == 0) main_plot->remove_tmpfiles(); 
} 


    void rysuj_wagi(int numer, Gnuplot * main_plot)
{
  std::ostringstream oss;
  oss <<"set output 'waga" << numer<<".png'";
  string output = oss.str();
  cout<<output;
  main_plot->cmd(output); 
  main_plot->set_grid(); 
  main_plot->set_xrange(-5,5);
  main_plot->set_yrange(-5,5);
  main_plot->set_style( "linespoints" );
  main_plot->set_pointsize( 1.0 );  
  vector<double> x, y;
  x.push_back(0); 
  y.push_back(0);
  x.push_back(punktyWagX[numer]);
  y.push_back(punktyWagY[numer]);
  main_plot->reset_plot();
  main_plot->plot_xy(x, y); 
}   

你碰巧知道出路吗?

1 个答案:

答案 0 :(得分:0)

您似乎正在使用此API:http://jfi.uchicago.edu/~tcaswell/track_doc/classgnuplot_1_1Gnuplot.html

你有没有试过这样的事情:

main_plot->cmd("set terminal pngcairo\n");         
//some setting of YOUR_FILENAME
main_plot->cmd("set output 'YOUR_FILENAME'\n");
main_plot->cmd("replot\n");

您可以希望一起避免临时文件。

相关问题