Simone Zuccher Simone Zuccher

Programming

gnuplot2ps-fig.plt

############################################################################
# \PURPOSE
#    To create nice postscript figures out of a gnuplot plot
#
# \USAGE
#    from the command line in gnuplot, execute the command
#         call 'gnuplot2ps-fig.plt' 'filename' 
#
# \DATE
#    03 Jun 2005
#
# \AUTHOR
#    Simone Zuccher
#
# \PHILOSOPHY
#    First set the correct paramenter in gnuplot and then export the figure
#    in pslatex format. By running LaTeX on a LaTeX file properly created
#    a ps file is obtained, then the BoundingBox is set to the correct
#    paramenters.
#
# \INPUT(S)
#    The name of the output file, filename
#
# \OUTPUT(S)
#    filename.ps
#
############################################################################

# set the correct terminal
set term pslatex

# set the output file name
set output '$0-tmp.tex'

# set the ratio between x and y axis
set size 0.7,0.9

# set the legend spacing
set key spacing 1.1

# replot whatever was plotted in the gnuplot window
rep

# reset the original size
set size 1,1

# reset the original legend spacing
set key spacing 1.25

# reset the screen as terminal
set term x11


# the following lines execute bash commands and create the .tex file
! TMP_FILE.tex="/tmp/tmp-gnuplot2ps-fig"
! echo \\documentclass[12pt]{article} > $TMP_FILE.tex
! echo \\setlength{\\topmargin}{-40 mm} >> $TMP_FILE.tex
! echo \\setlength{\\oddsidemargin}{-25 mm} >> $TMP_FILE.tex
! echo \\setlength{\\textwidth}{200 mm} >> $TMP_FILE.tex
! echo \\setlength{\\textheight}{200 mm} >> $TMP_FILE.tex
! echo \\setlength{\\footskip}{0 mm} >> $TMP_FILE.tex
! echo \\usepackage{graphics} >> $TMP_FILE.tex
! echo \\usepackage{amsmath} >> $TMP_FILE.tex
! echo %%BoundingBox: 0 565 390 855 >> $TMP_FILE.tex
! echo %%Old: 0 0 596 842 >> $TMP_FILE.tex
! echo \\pagestyle{empty} >> $TMP_FILE.tex
! echo \\begin{document} >> $TMP_FILE.tex
! echo \\input{$0-tmp.tex} >> $TMP_FILE.tex
! echo \\end{document} >> $TMP_FILE.tex

# moves the temporary file into the wanted one
! mv $TMP_FILE.tex $0.tex

# run latex
! latex $0.tex

# make the postscript file
! dvips -o $0.ps $0.dvi

# change the BoundingBox in the ps file
! sed s/'BoundingBox: 0 0 596 842'/'BoundingBox: 12 650 275 855'/ < $0.ps > $TMP_FILE.ps

# remove temporary files
! rm -f $0.*
! rm -f $0-tmp.tex
# get the correct file
! mv $TMP_FILE.ps $0.ps

# remove temporary files
! rm -f $TMP_FILE*
Top
Last updated: 18 Oct 2007. Webmaster