#! /bin/sh while [ $# -gt 0 ] do if [ $1 = "-L" -o $1 = "-Lxy" ] then SCALE="set logscale" elif [ $1 = "-Lx" ] then SCALE="set logscale x" elif [ $1 = "-Ly" ] then SCALE="set logscale y" elif [ $1 = "-Tpng" ] then TERMINAL="set terminal pngcairo" fi shift done /usr/bin/awk ' BEGIN { SCALE = "'"$SCALE"'" TERMINAL = "'"$TERMINAL"'" nf = N = L = 0 if (TERMINAL != "") { print TERMINAL } print "set multiplot" if (SCALE != "") print SCALE } /^#/ { next } /^$/ { if (N > 0) plot() next } /^s/ { print "set title \047" substr($0, 3) "\047" next } /^v/ { print "set origin", $2 "," $4 print "set size", ($3 - $2) "," ($5 - $4) next } /^wx/ { if (NF == 3) { print "set logscale x" print "set xtics 10" print "set xrange [" 10^$2 ":" 10^$3 "]" next } print "set xrange [" $2 ":" $3 "]" if (NF == 5) { print "set xtics", $4 print "set mxtics", $4 / $5 } else if (NF == 4) print "set xtics", $4 next } /^wy/ { if (NF == 3) { print "set logscale y" print "set yrange [" 10^$2 ":" 10^$3 "]" print "set ytics 10" next } print "set yrange [" $2 ":" $3 "]" if (NF == 5) { print "set ytics", $4 print "set mytics", $4 / $5 } else if (NF == 4) print "set ytics", $4 next } /^x/ { print "set xlabel \047" substr($0, 3) "\047" next } /^y/ { print "set ylabel \047" substr($0, 3) "\047" next } /^l/ { label[L++] = substr($0, 3) next } { for (i = 1; i <= NF; i++) d[N, i] = $i N++ if (nf == 0) nf = NF else if (nf != NF) print "abnormal record", $0 >"/dev/stderr" } END { if (N > 0) plot() } function plot( i, j, k) { k = 0 printf "plot \"-\" title \"" label[k++] "\" with lines" w = "" for (i = 2; i < nf; i++) printf ", \"-\" title \"" label[k++] "\" with lines" printf "\n" for (i = 2; i <= nf; i++) { for (j = 0; j < N; j++) print d[j, 1], d[j, i] print "e" } for (i = 0; i < L; i++) label[i] = "" w = "" nf = N = L = 0 print "reset" } ' | gnuplot -persist