#! /bin/bash 
# Last edited on 2016-04-10 22:48:57 by stolfilocal

# Arguments:
#
#   {TEST_NAME}
#
# where
#
# Reads standard inputs, writes plot file to standard output


tname="$1"; shift # Test name

tmp="/tmp/$$"

datafile="${tmp}.gain"
fullpngfile="${tmp}_full.png"
outpngfile="${tmp}.png"

cat > ${datafile}

show="SHOW"

export GDFONTPATH=.

gnuplot <<EOF
set term png size 3200,1600 font "courbd,24"
set output "${fullpngfile}"
set title "Camera gain -- dataset ${tname}"

set grid xtics lt 1 lw 3 lc rgb '#ffddaa', lt 1 lw 1.5 lc rgb '#ffddaa'
set grid mxtics

set grid ytics lt 1 lw 3 lc rgb '#ffddaa', lt 1 lw 1.5 lc rgb '#ffddaa'
set grid mytics

set yrange [0.5:2.2]

# set key top left
unset key

plot \
  "${datafile}" using 1:3  title "gain"  with linespoints      pt 7 ps 1.3 lt 1 lw 2.0 lc rgb '#0055ff'
quit
EOF

convert ${fullpngfile} -resize '50%' ${outpngfile}

if [[ "/${show}" == "/SHOW" ]]; then
  display ${outpngfile}
fi

cat ${outpngfile}

rm -fv ${tmp}{-*,}.*
