gnuplotでのEPSファイルの作り方
後輩から聞かれた際にすぐに簡単なサイトが見つからなかったのでメモ書き.
EPSファイルの作り方
gnuplotで,
set term postscript eps enhanced color 20
set output "output.eps"
plot "test.txt"
を実行するとtest.txtの中身をグラフにしたものがoutput.epsとして作成されます.
pltファイル
pltファイルを使うと便利です.
上記のgnuplotで実行した内容をplot.pltファイルに入れておき,terminalで
gnuplot plot.plt
を実行するだけで,上記の内容が実行されます.
EPSからPDFに変換する方法
PDFに変換したい場合にはterminalで
pstopdf test.eps
または
epstopdf test.eps
を実行するとtest.pdfが作成されます.
PDFのバウンディングボックスの確認方法
TeXを実行した際にバウンディングボックスがわからないと怒られる時がある.そのような時はterminalで
gs -sDEVICE=bbox -dBATCH -dNOPAUSE test.pdf
を実行する(参考リンク)と
GPL Ghostscript 10.03.1 (2024-05-02)
Copyright (C) 2024 Artifex Software, Inc. All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Processing pages 1 through 1.
Page 1
%%BoundingBox: 5 3 356 248
%%HiResBoundingBox: 5.526000 3.438000 355.823989 247.733992
というように出力される.この場合のバウンディングボックスは5 3 356 248なので,
\begin{figure}[h]
\centering
\includegraphics[width=\columnwidth, bb = 5 3 356 248]{test.pdf}
\caption{Test}
\end{figure}
と指定すると「バウンディングボックスがわからない」という指摘は解決されることがある.
pltファイルの一例
set term postscript eps enhanced color 20
set xlabel "{/=20 time}"
set ylabel "{/=20 position}"
#set logscale x
#set logscale y
#set format x "10^{%L}"
#set format y "10^{%L}"
#set lmargin 8
#set bmargin 4
set tics font "Arial,30"
#set ytics 1e+2
set key right bottom
set key title " "
#-----------------------------------------------
set xrange [0:300]
set output "output.eps"
set yrange [0:1200]
plot "output.txt"
#pause -1