ARGH
[matches/honours.git] / research / TCS / plot2.sh~
1 #!/bin/bash
2
3 # Script to plot .dat files
4
5 x=2
6 echo "$x"
7 toplot="3"
8 ylabel="Counts"
9 style="p"
10 dir="/home/sam/Documents/University/honours/research/TCS"
11
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')
15
16 if [ "$title" == "" ]; then
17         title=$comment
18 else
19         title="$title\n$comment"
20 fi
21 filename=$(echo $1 | sed -e "s:$dir::g")
22 title="$filename\n$title"
23
24 xlabel=$(echo $labels | tr " " "\n" | head --lines=$x | tail --lines=1)
25 if [ "$2" != "" ]; then
26         if [ "$2" == "$1" ]; then
27                 exit 1
28         fi
29         command="set term png size 1024,800; set output \"$2\""
30 else
31         command=""
32 fi
33
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]"
39 plot="plot "
40 for y in $toplot; do
41         lab=$(echo $labels | tr " " "\n" | head --lines=$y | tail --lines=1)
42         if [ "$lab" == "" ]; then
43                 lab=$y
44         fi
45         plot="$plot \"$1\" u "$x":$y w $style t \"$1\","
46 done
47 plot=$(echo $plot | sed -e "s/,//$(echo $toplot | wc -w)")
48
49 if [ "$3" != "" ]; then
50         plot="$plot, \"$3\" u "$x":$y w $style t \"$3\""
51 fi
52         
53
54 command="$command; $plot; exit"
55
56 gnuplot="/usr/bin/gnuplot"
57 $gnuplot --persist -e "$command"
58
59
60
61

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