#! /bin/bash
# Plots an histogram produced by {pgmhist}, generates an EPS image.

# Usage: "plot_pgm_hist.sh {TITLE} {MAXVAL} {HISTFILE} > {FIGURE}.eps

title="$1"; shift
maxval="$1"; shift
hist_file="$1"; shift

temp="/tmp/$$"

eps_file="${temp}.eps"

gnuplot <<EOF
set term postscript eps color linewidth 2.0 "TimesRoman" 18
set output "${eps_file}"
maxval = ${maxval}
xoff = int(maxval/20 + 1)
set xrange [(-xoff):(maxval+xoff)]
set yrange [0.1:]
set logscale y
plot "${hist_file}" using 1:2 title "${title}" with histeps 
quit
EOF

cat ${eps_file}
rm -f ${eps_file}
