blob: de709f3c69f112d5492625f0c8eed66a0b5838b9 (
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#!/bin/bash
#NICE="blacktext linewidth 4.0 \"Helvetica\" 16 "
# try thinner lines
NICE="color blacktext solid linewidth 1.0 \"Helvetica\" 20 size 16cm,7cm"
EXT="png"
TERMINAL="png size 1024,768 large"
GRAPH=points
XTRA=
while true; do
case $1 in
--eps)
shift
EXT="eps"
TERMINAL="postscript eps $NICE"
;;
--lines)
shift
GRAPH=lines
;;
--xrange)
shift
XRANGE="set xrange [$1:$2]"
shift
shift
;;
--xticks)
shift
XTICKS="set xtics $1, $2"
shift
shift
;;
--yrange)
shift
YRANGE="set yrange [$1:$2]"
shift
shift
;;
--yticks)
shift
YTICKS="set ytics $1, $2"
shift
shift
;;
--extra)
shift
XTRA="$1"
;;
--linespoints)
shift
GRAPH=linespoints
;;
--*)
echo "unrecognized option: $1"
exit 1
;;
*)
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}"
KEY="set key below"
KEY="set key off"
gnuplot <<EOM
set terminal $TERMINAL
set out '/dev/null'
$YRANGE
$YTICKS
$XRANGE
$XTICKS
$PLOT
set ylabel '$YLABEL'
set xlabel '$XLABEL'
set title '$TITLE'
$KEY
set data style $GRAPH
set out '$OUT'
replot
set out
EOM
if [ "$EXT" == "eps" ]; then
ps2pdf -dEPSCrop $OUT
fi
|