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)
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"
39 lab=$(echo $labels | tr " " "\n" | head --lines=$y | tail --lines=1)
40 if [ "$lab" == "" ]; then
43 plot="$plot \"$1\" u $x:$y w $style t \"$lab\","
46 plot=$(echo $plot | sed -e "s/,//$(echo $toplot | wc -w)")
47 command="$command; $plot; exit"
49 gnuplot="/usr/bin/gnuplot"
50 $gnuplot --persist -e "$command"