blob: 1a455c58dd0327d9442a62487c6608c5d831533d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#!/bin/bash
#NICE="blacktext linewidth 4.0 \"Helvetica\" 16 "
# try thinner lines
NICE="blacktext linewidth 1.0 \"Helvetica\" 16 "
EXT="png"
TERMINAL="png picsize 1024 768"
GRAPH=points
while true; do
case $1 in
--eps)
shift
EXT="eps"
TERMINAL="postscript color eps $NICE"
;;
--lines)
shift
GRAPH=lines
;;
--linespoints)
shift
GRAPH=linespoints
;;
*)
break
;;
esac
done
OUT=$1
XLABEL=$2
YLABEL=$3
TITLE=$4
shift 4
PLOT="plot "
while [ ! -z "$1" ] && [ ! -z "$2" ] && [ ! -z "$3" ] && [ ! -z "$4" ]; do
CSV=$1
COL1=$2
COL2=$3
NAME=$4
PLOT="$PLOT '${CSV}' using ${COL1}:${COL2} title '${NAME}' with $GRAPH"
shift 4
if [ ! -z "$1" ]; then
PLOT="$PLOT, "
fi
# fixup csv file, gnuplot is picky
sed -i -e 's/,\([^ ]\)/, \1/g' "$CSV"
done
#echo $OUT
#echo $XLABEL
#echo $YLABEL
#echo $TITLE
#echo $PLOT
if [ "$PLOT" = "plot " ]; then
echo "Usage: $0 [--eps] <outfile> <X label> <Y label> <title> "\
"(<csv file> <column1> <column2> <label>)+"
exit 1
fi
OUT="${OUT}.${EXT}"
gnuplot <<EOM
set terminal $TERMINAL
set out '/dev/null'
$YRANGE
$XRANGE
$PLOT
set ylabel '$YLABEL'
set xlabel '$XLABEL'
set title '$TITLE'
set key below
set data style $GRAPH
set out '$OUT'
replot
set out
EOM
if [ "$EXT" == "eps" ]; then
ps2pdf -dEPSCrop $OUT
fi
|