3 # Script to plot .dat files
9 dir="/home/sam/Documents/University/honours/research/TCS"
11 title=$(grep "# Title = " $1 | sed 's/# Title = //g')
12 comment=$(grep "# Comment = " $1 | sed 's/# Comment = *//1' | head --bytes=100)
13 labels=$(grep -A 1 "# Data:" $1 | tail --lines=1 | sed 's/#//1')
15 if [ "$title" == "" ]; then
18 title="$title\n$comment"
20 filename=$(echo $1 | sed -e "s:$dir::g")
21 title="$filename\n$title"
23 xlabel=$(echo $labels | tr " " "\n" | head --lines=$x | tail --lines=1)
24 if [ "$2" != "" ]; then
25 if [ "$2" == "$1" ]; then
28 command="set term png size 1024,800; set output \"$2\""
33 command="$command; set title \"$title\""
34 command="$command; set xlabel \"$xlabel\""
35 command="$command; set ylabel \"$ylabel\""
36 command="$command; set key outside right"
37 #command="$command; set yrange [0:1]"
40 lab=$(echo $labels | tr " " "\n" | head --lines=$y | tail --lines=1)
41 if [ "$lab" == "" ]; then
44 plot="$plot \"$1\" u $x:$y w $style t \"$1\","
46 plot=$(echo $plot | sed -e "s/,//$(echo $toplot | wc -w)")
48 if [ "$3" != "" ]; then
49 plot="$plot, \"$3\" u $x:$y w $style t \"$3\""
53 command="$command; $plot; exit"
55 gnuplot="/usr/bin/gnuplot"
56 $gnuplot --persist -e "$command"