#
# Plot data using GNUPLOT
#
macro gnuplot
macro ple <- plevel
macro curr <- ls
kee %1 %2
eval (define a1 #f)
eval (define a2 #f)
eval (if (equal? (loctyp "%1") "a") (begin (set! a1 #t) (run "recast %1")))
eval (if (equal? (loctyp "%2") "a") (begin (set! a2 #t) (run "recast %2")))
write %%.dat 
out gnuplot%%.inp
eval (if a1 (begin (display "set xrange [-0.5:1.5]") \
                   (newline) \
                   (display "set xtics ('no' 0, 'yes' 1)")) \
            (display "#"))
eval (if a2 (begin (display "set yrange [-0.5:1.5]") \
                   (newline) \
                   (display "set ytics ('no' 0, 'yes' 1)")) \
            (display "#"))
echo set xlabel "%1"  font "Helvetica,15"
echo set ylabel "%2"  font "Helvetica,15"
echo plot "%%.dat" using 6:7 notitle with points pt 7 ps 2
out
eval (if a1 (run "recast %1"))
eval (if a2 (run "recast %2"))
undrop
keep %curr
echo +-----------------------------------------------------------------------+
echo | Starting GNUPLOT plotting program                                     |
echo | Useful commands include:                                              |
echo |   set xlabel "<string>"      reset X-axis label                       |
echo |   set ylabel "<string>"      reset X-axis label                       |
echo |   set xrange [<num>:<num>]   reset X-axis range for graph             |
echo |   set yrange [<num>:<num>]   reset Y-axis range for graph             |
echo |   set terminal               show or set terminal type eg windows     |
echo |   replot                     replot the plot with any new settings    |
echo |   help                       Gnuplot online help                      |
echo |   quit                       return to Sib-pair                       |
echo +-----------------------------------------------------------------------+
echo
$ gnuplot gnuplot%%.inp -
set ple -1 silent
file delete %%.dat gnuplot%%.inp
set ple %ple silent
;;;;
