我想写的结果gnuplot操作到PNG文件,这成功了,但我需要生成大约100 PNG文件,在这里我遇到了问题,因为我收到一个错误,“最大数量的临时文件gnuplot是27“。当我使用方法remove_tmpfiles()时,所有图像都可以正确生成,但其中大约20-30个是不可打开的。当我仅保存推荐的27张图像时,不会出现此错误。Gnuplot保存很多图像
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);
}
你碰巧知道出路吗?
哪些文件无法打开?尝试添加'main_plot-> cmd(“set output”);'在函数'rysuj_wagi'的末尾。只有在遇到新的'set output'文件名''时,Gnuplot才会完成输出文件。也许这会干扰'remove_tmpfiles()'。为了避免这种情况发送'set output'(是的,没有文件名)可能会有所帮助。 – Christoph
它始终没有创建关于每25个最后10个图像。您的解决方案的作品,但我删除temp_files()约4个100不可打开的情况下。我的想法是,它删除temp_file过快,所以我强迫它睡一会儿(int j = 0; j <100; j ++) rysuj_wagi(j,main_plot);如果(j == 25 || j == 50 || j == 75)(\t \t main_plot-> remove_tmpfiles(); } },这也适用。感谢您的努力。 – Maximus