#!/bin/sh
############################################################################
#
############################################################################
#

plotFile(){
	n=8
	cmd="
set multiplot;
set format x \"\";
set lmargin 8;
set bmargin 0;
set tmargin 1;
set grid noytics xtics;"

for ((i=0; i < n; i++)); do
	p=`expr $i + 1`
	o=`expr \( $n - $i \) * 1`
	echo "$p $o"
	cmd="$cmd 
	set origin 0,0.8;
	set size 1,0.1;
	plot '$1' using $p with lines;"
done

	cmd="$cmd 
set origin 0,0.8;
set size 1,0.2;
plot '$1' using 1 with lines;

set origin 0,0.6;
set size 1,0.2;
set format x \"%g\";
plot '$1' using 5 with lines;
"

cmd="$cmd 
unset multiplot;
pause -1;
pause 10;
"

	echo ${cmd}
	echo $cmd | gnuplot -
	sleep 6
}

plotFile $1
