#! /bin/bash
# Last edited on 2019-08-05 01:38:30 by jstolfi
# Plots the 9 variants of a basic plot.

namper="$1"; shift;

tmp="/tmp/$$"
tfile="${tmp}_t.png"

export GDFONTPATH="."
gnuplot <<EOF
  set term png truecolor size 800,800 font "arial,18"
  set size ratio -1
  set output "${tfile}"
  set xrange [-0.0005:1.0005]
  set yrange [-0.0005:1.0005]
  set xtics 0.1
  set format x ""
  set ytics 0.1
  set format y ""
  set key top left
  val(z) = ((z < 0) || (z > 1) ? 0/0 : z)
  plot \
    (x) notitle with lines lw 2 lt 1 lc rgb '#88aa99', \
    (1-x) notitle with lines lw 2 lt 1 lc rgb '#aa9988', \
    "out/${namper}_oooo.txt" using (val(column(1))):2 title "ref" with lines lw 2 lt 1 lc rgb '#cc0000', \
    "out/${namper}_ooop.txt" using (val(column(1))):2 title "+I"  with lines lw 2 lt 1 lc rgb '#bb6644', \
    "out/${namper}_ooom.txt" using (val(column(1))):2 title "-I"  with lines lw 2 lt 1 lc rgb '#cc0022', \
    "out/${namper}_oopo.txt" using (val(column(1))):2 title "+W"  with lines lw 2 lt 1 lc rgb '#55cc44', \
    "out/${namper}_oomo.txt" using (val(column(1))):2 title "-W"  with lines lw 2 lt 1 lc rgb '#339900', \
    "out/${namper}_opoo.txt" using (val(column(1))):2 title "+VS" with lines lw 2 lt 1 lc rgb '#00cc88', \
    "out/${namper}_omoo.txt" using (val(column(1))):2 title "-VS" with lines lw 2 lt 1 lc rgb '#cc7788', \
    "out/${namper}_pooo.txt" using (val(column(1))):2 title "+VT" with lines lw 2 lt 1 lc rgb '#3344ff', \
    "out/${namper}_mooo.txt" using (val(column(1))):2 title "-VT" with lines lw 2 lt 1 lc rgb '#4400cc'
  quit
EOF

if [[ -s ${tfile} ]]; then
  convert ${tfile} -resize '50%' out/${namper}_multi.png 
  display out/${namper}_multi.png
fi
