gnuplot
以下の連番ファイルを順に開いてグラフを自動生成したい.
result_01_0.1.txt
result_01_0.2.txt
↓
result_05_0.9.txt
result_05_1.0.txt
for分とsprintfを使用すればよい.
do for [I=1:5]{
do for [J:1:10]{
FILENAME_IN=sprinf("./result_%02d_%2.1f.txt", I, J/10.0)
FILENAME_OUT=sprinf("./result_%02d_%2.1f.png", I, J/10.0)
plot FILENAME_IN
set term ongcairo size 100,100
set output OUTFILENAME_OUT
}
}
コメント
%02d で 01, 02, 03, ..., 10 となる
%2 なら 1, 2, 3, .., 10 となる
ワンラインでfor分は do,{}は不要である.
%10.2fなら全部で10桁用意して小数点以下に2桁を配分.
J/10ではinteger自動的にintegerとして認識される.
文字列にタイトル,ファイル名などを入れておれけばスマート.
以下テンプレート
# !/user/bin/gnuplot
# 3次元plot
set ticslevel 0
# set cbrange[20:120]
# set palette define (20 "blue", 60 "white", 120 "red")
# set palette define (0 "navy",1 "blue",2 "dark-violet",3 "red",4 "yellow")
set palette rgbformulae 22, 13, -31
# set palette define (20 "white", 100 "red")
# set grid
set xtics 0.01 font "Times,10" offset 0,-1,0
set ytics 0.01 font "Times,10" offset 1,0,0
set ztics 0.01 font "Times,10" offset 0,0,0
set size ratio 1.0
set key left below
set cblabel "{/Times-New-Roman=10 Temp [℃]}"
set xlabel "{/Times-New-Roman=10 X [M]" offset 0,-1,0
set ylabel "{/Times-New-Roman=10 Y [M]" offset 1,0,0
set zlabel "{/Times-New-Roman=10 Z [M]" offset 0,0,0
set view equal xyz
set cbtics 10 font "Times,10" offset 1,0,0
# set colorbox user origin 0,0
set format cb "%.2f"
set arrow from 0.00,0.00,0.00 to 0.04,0.00,0.00 nohead lw 1 lc black front
set arrow from 0.00,0.04,0.00 to 0.04,0.04,0.00 nohead lw 1 lc black front
set arrow from 0.00,0.00,0.04 to 0.04,0.00,0.04 nohead lw 1 lc black front
set arrow from 0.00,0.04,0.04 to 0.04,0.04,0.04 nohead lw 1 lc black front
set arrow from 0.00,0.00,0.00 to 0.00,0.00,0.04 nohead lw 1 lc black front
set arrow from 0.04,0.00,0.00 to 0.04,0.00,0.04 nohead lw 1 lc black front
set arrow from 0.04,0.04,0.00 to 0.04,0.04,0.04 nohead lw 1 lc black front
set arrow from 0.00,0.04,0.00 to 0.00,0.04,0.04 nohead lw 1 lc black front
set arrow from 0.00,0.00,0.04 to 0.00,0.04,0.04 nohead lw 1 lc black front
set arrow from 0.04,0.00,0.04 to 0.04,0.04,0.04 nohead lw 1 lc black front
set arrow from 0.04,0.00,0.00 to 0.04,0.04,0.00 nohead lw 1 lc black front
set arrow from 0.00,0.00,0.00 to 0.00,0.04,0.00 nohead lw 1 lc black front
splot for [j=0:100:5] "result/result_05_0.020.txt" every ::: (j*201+0) :: (j*201+200) with pm3d not
do for [N_FIN=05:16]{
do for [H_FIN=20:38:2]{
FILENAME = sprintf("result/result_%02d_%4.3f.txt",N_FIN,H_FIN/1000.0)
OUTFILENAME1 =sprintf("img_png/result_%02d_%4.3f.png",N_FIN,H_FIN/1000.0)
OUTFILENAME2 =sprintf("img_emf/result_%02d_%4.3f.emf",N_FIN,H_FIN/1000.0)
TITLE = sprintf("n_{fin} = %02d, h_{fin} = %4.3f",N_FIN,H_FIN/1000.0)
set title TITLE
splot for [j=0:100:5] FILENAME every ::: (j*201+0) :: (j*201+200) with pm3d not
set term pngcairo size 600,600
set output OUTFILENAME1
replot
# set term x11
set term emf enhanced
set output OUTFILENAME2
replot
set term x11
}}
以上