#! /bin/bash
# Last edited on 2018-01-15 19:29:02 by jstolfi

# Plots solub_NH4_H2PO4_cooked.txt

tmp="/tmp/$$"
ifile="solub_NH4_H2PO4_cooked.txt"
tfile="${tmp}.txt"

gawk '(($18)+0 > 0) { print; }' ${ifile} > ${tfile}

gnuplot <<EOF
  set term X11 size 640,960
  
  set yrange [10.0:]
  set logscale y
  set xrange [-6:166]
  set xtics 5
  set mxtics 5
  set grid xtics
  
  plot \
    "${ifile}"  using 2:20 with linespoints lt 1 pt 7 ps 1, \
    ""          using 2:18 with points lt 3 pt 6 ps 2, \
    (100)                  with lines lt 1, \
    "${tfile}"  using 2:(100+300*(column(18)/column(20)-1)) with linespoints lt 6 pt 7 ps 1
    
  pause 120
  quit
EOF
