2013-05-05 29 views
0

您好我正在使用gnuplot来创建大量的图。为了节省工作量,我编写了一个脚本,试图绘制所有可能的图表。Gnuplot嵌套做循环和在同一个图上绘图

#!/usr/bin/gnuplot 

reset 
is_missing(x)=system("./ismissing.sh ".x) 
set terminal post eps enhanced color 
set key inside right top vertical Right noreverse enhanced autotitles box linetype -1 linewidth 1.000 
set grid 
models="Cebeci-Smith Baldwin-Lomax Spalart-Allmaras Launder-Sharma Chien" 
files="./CebeciOut/ ./BaldwinOut/ ./SpalartOut/ ./LaunderOut/ ./ChienOut/" 
xgrid="35000 70000 140000 280000 560000" 

# Plot grid convergence Spalart 
do for [f=1:words(files)]{ 
    set output sprintf('%s%s',word(files,f),'ZPGGridConvergence.eps') 
    set title sprintf("%s%s",word(models,f), " ZPG Grid Convergence") 
    set xlabel "N_y" 
    set ylabel "C_f Final" 
    print f 
    do for [i=1:words(xgrid)]{ 
     filename=sprintf("%s%s%s%s",word(files,f),'yconv_',word(xgrid,i),"x") 
     if(is_missing(filename)==0){ 
      plot filename using 1:2 title sprintf("%s%s",word(xgrid,i), " X Gridpoints") with linespoints 
     } 
    } 
} 

不幸的是我有一个问题,一个完整的迭代的脚本失败后,IE F从未尽管第一地块成功完成了2。给出的错误是

cannot open file; output not changed 
line 25: util.c: No such file or directory 

我没有设法解密。任何帮助将非常感激。还有一种方法可以在这个循环中使用replot,因为我还没有创建一个图。 谢谢

回答

1

“文件”实际上是代码中的dirs。

如果您想将输出放置在子目录中,请确保它存在且可写。

gnuplot无法自动创建子目录。您可以在代码中添加system("mkdir -p ".word(files,f))(在linux/unix上)以根据需要创建目录。