summaryrefslogtreecommitdiff
path: root/csv2plot
diff options
context:
space:
mode:
Diffstat (limited to 'csv2plot')
-rwxr-xr-xcsv2plot67
1 files changed, 67 insertions, 0 deletions
diff --git a/csv2plot b/csv2plot
new file mode 100755
index 0000000..fbb250f
--- /dev/null
+++ b/csv2plot
@@ -0,0 +1,67 @@
+#!/bin/sh
+#
+# rudimental script to plot two csv data sets
+#
+# Copyright (c) 2015, Aliaksei Katovich <aliaksei.katovich at gmail.com>
+#
+# Licensed under the GNU General Public License version 2 (GPLv2).
+
+color1="#000070"
+color2="#007000"
+
+bg="grey80"
+fg="black"
+
+_init()
+{
+ echo "set obj 1 rectangle behind from screen 0,0 to screen 1,1"
+ echo "set obj 1 fillstyle solid 1.0 fillcolor rgb '$bg'"
+ echo "set term wxt font 'Arial Bold,9'"
+
+ echo "set title '$name1 vs $name2' tc rgb '$fg'"
+ echo "set key left Left"
+ echo "set key tc rgb '$fg'"
+ echo "set xtic auto"
+ echo "set xlabel 'Time in seconds' tc rgb '$fg' offset 0,-4"
+ echo "set xtics rotate by 90 offset 0,-4"
+
+ echo "set ylabel '$name1 (mA)' tc rgb '$color1'"
+ echo "set ytic auto nomirror tc lt 1"
+
+ echo "set y2label '$name2 (mA)' tc rgb '$color2'"
+ echo "set y2tic auto nomirror tc lt 2"
+
+ echo "set border 1 lt rgb '$fg'"
+ echo "set grid lt 0 lw 1 lc rgb '$fg'"
+
+ echo "set ytics tc rgb '$fg'"
+ echo "set y2tics tc rgb '$fg'"
+ echo "set style data lines"
+
+ echo "set datafile separator ','"
+
+ echo "f(x) = mean_y"
+ echo "fit f(x) '$file1' u 1:3 via mean_y"
+ echo "f(x) = mean_y2"
+ echo "fit f(x) '$file2' u 1:3 via mean_y2"
+
+ echo -n "plot '$file1' u 1:3 "
+ echo -n "title sprintf('$name1 mean %.06f mA', mean_y) "
+ echo -n "lt 1 lc rgb '$color1' axes x1y1,"
+ echo -n "'$file2' u 1:3 "
+ echo -n "title sprintf('$name2 mean %.06f mA', mean_y2) "
+ echo "lt 2 lc rgb '$color2' axes x1y2"
+}
+
+file1=$1
+file2=$2
+
+if [ -z "$file2" ]; then
+ echo "Usage: $(basename $0) <data1.csv> <data2.csv>"
+ exit 1
+fi
+
+name1=$(basename $file1)
+name2=$(basename $file2)
+
+_init | gnuplot -noraise -p