diff options
author | Bjoern Brandenburg <bbb@bbb1-cs.cs.unc.edu> | 2008-09-04 10:16:41 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@bbb1-cs.cs.unc.edu> | 2008-09-04 10:16:41 -0400 |
commit | bafc8b528bcc589b68a467214c1f55b2903b6419 (patch) | |
tree | 92e2b4aa7b7b4f1799522048e91d49b3658cc59f | |
parent | 156b45e57f3e5c91991a3fe7b026edf8c0a84aa4 (diff) |
add scatter plottin support
-rwxr-xr-x | plot_scatter | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/plot_scatter b/plot_scatter new file mode 100755 index 0000000..c92c11a --- /dev/null +++ b/plot_scatter | |||
@@ -0,0 +1,74 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | #NICE="blacktext linewidth 4.0 \"Helvetica\" 16 " | ||
4 | |||
5 | # try thinner lines | ||
6 | NICE="blacktext linewidth 1.0 \"Helvetica\" 16 " | ||
7 | |||
8 | if [ "$1" == "--eps" ]; then | ||
9 | EXT="eps" | ||
10 | TERMINAL="postscript color eps $NICE" | ||
11 | shift | ||
12 | else | ||
13 | EXT="png" | ||
14 | TERMINAL="png picsize 1024 768" | ||
15 | fi | ||
16 | |||
17 | |||
18 | OUT=$1 | ||
19 | XLABEL=$2 | ||
20 | YLABEL=$3 | ||
21 | TITLE=$4 | ||
22 | shift 4 | ||
23 | |||
24 | PLOT="plot " | ||
25 | |||
26 | |||
27 | while [ ! -z "$1" ] && [ ! -z "$2" ] && [ ! -z "$3" ] && [ ! -z "$4" ]; do | ||
28 | CSV=$1 | ||
29 | COL1=$2 | ||
30 | COL2=$3 | ||
31 | NAME=$4 | ||
32 | PLOT="$PLOT '${CSV}' using ${COL1}:${COL2} title '${NAME}' with points" | ||
33 | shift 4 | ||
34 | if [ ! -z "$1" ]; then | ||
35 | PLOT="$PLOT, " | ||
36 | fi | ||
37 | done | ||
38 | |||
39 | #echo $OUT | ||
40 | #echo $XLABEL | ||
41 | #echo $YLABEL | ||
42 | #echo $TITLE | ||
43 | #echo $PLOT | ||
44 | |||
45 | if [ "$PLOT" = "plot " ]; then | ||
46 | echo "Usage: $0 [--eps] <outfile> <X label> <Y label> <title> "\ | ||
47 | "(<csv file> <column1> <column2> <label>)+" | ||
48 | exit 1 | ||
49 | fi | ||
50 | |||
51 | OUT="${OUT}.${EXT}" | ||
52 | |||
53 | # fixup csv file, gnuplot is picky | ||
54 | #sed -i -e 's/,\([^ ]\)/, \1/g' $CSV1 | ||
55 | |||
56 | gnuplot <<EOM | ||
57 | set terminal $TERMINAL | ||
58 | set out '/dev/null' | ||
59 | $YRANGE | ||
60 | $XRANGE | ||
61 | $PLOT | ||
62 | set ylabel '$YLABEL' | ||
63 | set xlabel '$XLABEL' | ||
64 | set title '$TITLE' | ||
65 | set key below | ||
66 | set data style points | ||
67 | set out '$OUT' | ||
68 | replot | ||
69 | set out | ||
70 | EOM | ||
71 | |||
72 | if [ "$EXT" == "eps" ]; then | ||
73 | ps2pdf -dEPSCrop $OUT | ||
74 | fi | ||