カレントディレクトリを移動したいのは,参照したいファイルの絶対パスを取得するのが面倒くさいからと推察します.
そこで,以下を冒頭に書くことでカレントディレクトリが移動できます.
move.gp
max(x,y)= ( (x) > (y) ) ? (x) : (y)
strstrlt_sub(str,index,target)=(strstrt(str[index:],target)==0 ? \
max(index-strlen(target),0) : \
strstrlt_sub(str, index-1+strstrt(str[index:],target)+strlen(target),target))
strstrlt(str,target)=strstrlt_sub(str,1,target)
dirname(path)=strstrt(path, "\\")!= 0 ? substr(path, 1, strstrlt(path,"\\")-1) : ""
cd dirname(ARG0)
ところで,そもそもカレントディレクトリを移動しなくても,plt
ファイルを実行すれば,plt
ファイルのあるディレクトリのファイルを相対パスで取得できます.
グラフを取得するだけなら,plt
ファイルにて処理すると良いでしょう.
ただし,stats
コマンドを使うなどして入力データに対する標準偏差や平均値を使いたいということがあるかもしれません.(というか,筆者がそれでした)
そういうときは,gnuplot
を立ち上げて,上記のmove.gp
を書いたgp
ファイルをgnuplot
で実行すると良いでしょう.
※ PythonやFortranにおけるような,input関数的なやつがgnuplot
にあるなら,それを使えばいいのですが…探しても見つけられなかったので.
他にできそうなこと
釈迦に説法かとは存じますが,参考先のページにて,ファイル名の取得も紹介されています.
すなわち,plt
ファイルやgp
ファイルと同じ名前のeps
ファイルを作成する,という処理も,いちいち書き換えなくてもできそうです.
参考