もちろん,コマンドラインからだと入力できないですが,
プロットする命令とかをファイルに書いておいて,gnuplotに読み込ませれば簡単に出力できます.
たとえば,こんなファイル(test.plot)を作っておきます.
set terminal x11
set xlabel "n"
set ylabel "処理時間(秒)"
f(x) = 2**x
plot f(x) w l title "処理時間"
set xlabel "n"
set ylabel "処理時間(秒)"
f(x) = 2**x
plot f(x) w l title "処理時間"
これを実行するには,gnuplotを起動して,
gnuplot> load "test.plot"
でOKです.
でも,epsに出力するとなると,ちょっとやっかいです.
Ubuntuの場合,先ほどのグラフを test.eps に出力するには test.plot に次のように書きます.
set terminal postscript eps enhanced color "GothicBBB-Medium-EUC-H"
set output "test.eps"
set xlabel "n"
set ylabel "処理時間(秒)"
f(x) = 2**x
plot f(x) w l title "処理時間"
set output "test.eps"
set xlabel "n"
set ylabel "処理時間(秒)"
f(x) = 2**x
plot f(x) w l title "処理時間"
太字の部分で,フォントの指定をしています.もちろん,フォント指定なしでもOKですが,日本語を使うときは指定しないとダメみたいです.
Ubuntuの場合,LaTeXの文字コードはEUCなので,ちゃんとEUC指定しましょう.
それから,この test.plot も文字コードをEUCにしなければなりません.
これでeps出力できます.
でも・・・
文字小さくないですか?
gnuplotのeps出力ではグラフの大きさが変わっても,文字の大きさが変わりません.
しかもちいさい.
そこで,ちょっと工夫しましょう.
先ほどの test.plot (eps出力版)をちょっといじって,
set terminal postscript eps enhanced color "GothicBBB-Medium-EUC-H"
set output "test.eps"
set xlabel "n"
set ylabel "処理時間(秒)"
set size 0.7,0.7
f(x) = 2**x
plot f(x) w l title "処理時間"
set output "test.eps"
set xlabel "n"
set ylabel "処理時間(秒)"
set size 0.7,0.7
f(x) = 2**x
plot f(x) w l title "処理時間"
こんな感じにしましょう.
set size 0.7,0.7
でタテヨコの大きさが0.7倍になりますが,文字の大きさは変わりません.
あとはこれをtexに貼り付けるときに適当に拡大すれば,文字の大きさも丁度良くなります.
だいたい1.5倍くらいにすると,結構大きめな感じになりました.
0 件のコメント:
コメントを投稿