2013-05-05 105 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上)以根據需要創建目錄。