Automatic commit. Thu Oct 4 00:00:10 WST 2012
[matches/honours.git] / research / TCS / plot2.sh
1 #!/bin/bash
2
3 # Script to plot .dat files
4
5 x=2
6 toplot="3"
7 ylabel="Counts"
8 style="p"
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 if [ "$2" != "" ]; then
25         if [ "$2" == "$1" ]; then
26                 exit 1
27         fi
28         command="set term png size 1024,800; set output \"$2\""
29 else
30         command=""
31 fi
32
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]"
38 plot="plot "
39 for y in $toplot; do
40         lab=$(echo $labels | tr " " "\n" | head --lines=$y | tail --lines=1)
41         if [ "$lab" == "" ]; then
42                 lab=$y
43         fi
44         plot="$plot \"$1\" u $x:$y w $style t \"$1\","
45 done
46 plot=$(echo $plot | sed -e "s/,//$(echo $toplot | wc -w)")
47
48 if [ "$3" != "" ]; then
49         plot="$plot, \"$3\" u $x:$y w $style t \"$3\""
50 fi
51         
52
53 command="$command; $plot; exit"
54
55 gnuplot="/usr/bin/gnuplot"
56 $gnuplot --persist -e "$command"
57
58
59
60

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