# Script to plot .dat files
-x=1
-toplot="3 5 2"
+x=2
+toplot="3 5"
ylabel="Counts"
-style="l"
+style="p"
dir="/home/sam/Documents/University/honours/research/TCS"
title=$(grep "# Title: " $1 | sed 's/# Title: //g')
title="$filename\n$title"
xlabel=$(echo $labels | tr " " "\n" | head --lines=$x | tail --lines=1)
-command="set title \"$title\""
+if [ $2 != "" ]; then
+ if [ $2 == $1 ]; then
+ exit 1
+ fi
+ command="set term png size 1024,800; set output \"$2\""
+else
+ command=""
+fi
+
+command="$command; set title \"$title\""
command="$command; set xlabel \"$xlabel\""
command="$command; set ylabel \"$ylabel\""
command="$command; set key outside right"
plot=$(echo $plot | sed -e "s/,//$(echo $toplot | wc -w)")
command="$command; $plot; exit"
-
-gnuplot --persist -e "$command"
+gnuplot="/usr/bin/gnuplot"
+$gnuplot --persist -e "$command"