#! /bin/csh -f -e

set plotname = "$1:r"; shift
set script = "/tmp/$$.gnuplot"

if ( $#argv > 0 ) then
  set n = $1
else
  set n = 1
endif

set label = ( a b c d e f g h i j k l m n o p q r s t u v w x y z )

rm -f ${script}
set i = 1
echo 'set size 1.0,1.0' >> ${script}
echo 'set terminal postscript eps monochrome "Times-Roman" 16' >> ${script}
echo 'set output "'"${plotname}.ps"'"' >> ${script}
echo 'plot \' >> ${script}
while ( $i <= $n )
  if ( $i == $n ) then
    set comma = ''
  else
    set comma = ', \'
  endif
  @ k = $i + 1
  set lab = $label[$i]
  echo ' "'"${plotname}.plot"'" using 1:'"${k}"' title "('"${lab}"')" with lines'"${comma}" >> ${script}
  @ i = $i + 1
end
echo " " >> ${script}
echo "quit" >> ${script}

cat ${script}

${GNU_PUB}/bin/gnuplot < ${script}

${GNU_PUB}/bin/ghostview -magstep 2 ${plotname}.ps

/bin/rm -f ${script}
