gnuplotでのEPSファイルの作り方

後輩から聞かれた際にすぐに簡単なサイトが見つからなかったのでメモ書き.

set term postscript eps enhanced color 20
set output "output.eps"
plot "test.txt"

を実行するとtest.txtの中身をグラフにしたものがoutput.epsとして作成されます.


gnuplot plot.plt

を実行するだけで,上記の内容が実行されます.


pstopdf test.eps

または

epstopdf test.eps

を実行するとtest.pdfが作成されます.


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}

指定すると「バウンディングボックスがわからない」という指摘は解決されることがある.

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