Automatic commit. Wed Aug 1 14:00:02 WST 2012
[matches/honours.git] / research / TCS / plot.sh
1 #!/bin/bash
2
3 # Script to plot .dat files
4
5 x=1
6 toplot="3 5"
7 ylabel="Counts"
8 style="l"
9 dir="/home/sam/Documents/University/honours/research/TCS"
10
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')
14
15 if [ "$title" == "" ]; then
16         title=$comment
17 else
18         title="$title\n$comment"
19 fi
20 filename=$(echo $1 | sed -e "s:$dir::g")
21 title="$filename\n$title"
22
23 xlabel=$(echo $labels | tr " " "\n" | head --lines=$x | tail --lines=1)
24 command="set title \"$title\""
25 command="$command; set xlabel \"$xlabel\""
26 command="$command; set ylabel \"$ylabel\""
27 command="$command; set key outside right"
28 plot="plot "
29 for y in $toplot; do
30         lab=$(echo $labels | tr " " "\n" | head --lines=$y | tail --lines=1)
31         if [ "$lab" == "" ]; then
32                 lab=$y
33         fi
34         plot="$plot \"$1\" u $x:$y w $style t \"$lab\","
35 done
36         
37 plot=$(echo $plot | sed -e "s/,//$(echo $toplot | wc -w)")
38 command="$command; $plot; exit"
39
40
41 gnuplot --persist -e "$command"
42
43
44
45

UCC git Repository :: git.ucc.asn.au