3 # Script to plot .dat files
10 dir="/home/sam/Documents/University/honours/research/TCS"
12 title=$(grep "# Title = " $1 | sed 's/# Title = //g')
13 comment=$(grep "# Comment = " $1 | sed 's/# Comment = *//1' | head --bytes=100)
14 labels=$(grep -A 1 "# Data:" $1 | tail --lines=1 | sed 's/#//1')
16 if [ "$title" == "" ]; then
19 title="$title\n$comment"
21 filename=$(echo $1 | sed -e "s:$dir::g")
22 title="$filename\n$title"
24 xlabel=$(echo $labels | tr " " "\n" | head --lines=$x | tail --lines=1)
25 if [ "$2" != "" ]; then
26 if [ "$2" == "$1" ]; then
29 command="set term png size 1024,800; set output \"$2\""
34 command="$command; set title \"$title\""
35 command="$command; set xlabel \"$xlabel\""
36 command="$command; set ylabel \"$ylabel\""
37 command="$command; set key outside right"
38 #command="$command; set yrange [0:1]"
41 lab=$(echo $labels | tr " " "\n" | head --lines=$y | tail --lines=1)
42 if [ "$lab" == "" ]; then
45 plot="$plot \"$1\" u "$x":$y w $style t \"$1\","
47 plot=$(echo $plot | sed -e "s/,//$(echo $toplot | wc -w)")
49 if [ "$3" != "" ]; then
50 plot="$plot, \"$3\" u "$x":$y w $style t \"$3\""
54 command="$command; $plot; exit"
56 gnuplot="/usr/bin/gnuplot"
57 $gnuplot --persist -e "$command"