rubyでgnuplotのpltファイルを作る。行末コードの問題?
結論としては、gnuplotと行末コード、rubyで出力時に行末コードを選ぶ方法、を調べるべきだが、とりあえずメモ。
gnuplotのpltファイルをrubyで自動生成させている。gnuplotには
plot "file1.dat" with lines, "file2.dat" with lines, "file3.dat" with lines;
のように1行で与えるべきところを、hoge.pltのようなpltファイルを
plot "file1.dat" with lines,
"file2.dat" with lines,
"file3.dat" with lines;
のように作って、
としても同じ。このpltファイルをパラメタを変えて複数作る必要があったので、それだったらスクリプトで自動化させてしまおうと思い、
output="hoge.plt"
file=File.open output, "w"
file.puts "plot \"file1.dat\" with lines,"
file.puts "\"file2.dat\" with lines,"
file.puts "\"file3.dat\" with lines;"
file.close
のようなrubyのスクリプトに頑張ってもらおうとしたのだけど、
line 1 : function to plot expected
のように怒られた。
output="hoge.plt"
file=File.open output, "w"
file.puts "plot \"file1.dat\" with lines, \"file2.dat\" with lines, \"file3.dat\" with lines;"
file.close
としたら大丈夫だった。今までうまくいっていたpltファイルの行末コードはCRなのに対し、今回rubyに作らせたpltファイルのコードがLFなのが問題なのかもしれない。