#! /bin/bash
# Last edited on 2019-03-25 02:49:16 by jstolfi

export GDFONTPATH=${HOME}/

pfile="p2c_out_plot.png"

rm -f ${pfile}

gnuplot <<EOF
# set term x11 size 800,800
set term png size 1600,1600 linewidth 2 noenhanced font "arial,14"
set output "${pfile}"
set title "Map coordinates"

set size ratio -1

set xrange [31.35:31.85]
# set xrange [31.1:31.9]
# set xrange [30.9:31.3]
set xtics 0.5
set mxtics 5
set grid mxtics

set yrange [4.95:5.25]
# set yrange [4.9:5.3]
# set yrange [4.5:5.0]
set ytics 0.5
set mytics 5
set grid mytics

plot \
  "p2c_out_T.txt" using 1:2 title "T" with points pt 7 ps 1.2 lc rgb '#008800', \
  "p2c_out_T.txt" using 1:2:4 notitle with labels left offset 0.2,0.7 lc rgb '#008800', \
   \
  "p2c_out_U.txt" using 1:2 title "U" with points pt 2 ps 2.4 lc rgb '#0033ff', \
  "p2c_out_U.txt" using 1:2:4 notitle with labels left offset 0.2,0.7 lc rgb '#0033ff', \
   \
  "p2c_out_R.txt" using 1:2 title "R" with points pt 1 ps 3.0 lc rgb '#aa2200', \
  "p2c_out_R.txt" using 1:2:4 notitle with labels left offset 0.2,0.7 lc rgb '#aa2200', \
   \
  "p2c_out_G.txt" using 1:2 title "G" with points pt 6 ps 2.0 lc rgb '#7700ff', \
  "p2c_out_G.txt" using 1:2:4 notitle with labels left offset 0.2,0.7 lc rgb '#7700ff'
EOF

if [[ -s ${pfile} ]]; then
  bash -c "display -resize '50%' ${pfile} & "
  exit 0
fi
