]> git.itanic.dy.fi Git - log-plotter/blobdiff - volt_cur.plot
Add improved gnuplot scripts
[log-plotter] / volt_cur.plot
diff --git a/volt_cur.plot b/volt_cur.plot
new file mode 100644 (file)
index 0000000..4604338
--- /dev/null
@@ -0,0 +1,63 @@
+#
+#    Tero Salminen 2013 for project Log-plotter
+#    Timo Kokkonen http://git.itanic.dy.fi/?p=log-plotter
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+#    Commandline usage with example values unless ran from log-plotter
+#    directly:
+#    gnuplot -e "datafile='log.log' ; chg_name='iCharger 3010B' ; cell_cnt='6' ; sizex='800' ; sizey='480'" volt_cur.plot
+
+set output "volt_cur.png"
+
+# Build title
+ttext1=" - Battery voltage & charged capacity "
+ttext2="S battery"
+set title chg_name.ttext1.cell_cnt.ttext2
+
+# Setting the graphics size from log-plotter variables
+gsizex=sizex
+gsizey=sizey
+set term png size gsizex,gsizey
+
+# Setting layout and label & legends etc
+set lmargin 10
+set rmargin 10
+set tmargin 3
+set datafile separator ";"
+set key out bot hor center samplen 2
+set timestamp "%d.%m.%Y - %H:%M" top offset -1,-1 font ",8"
+set ylabel "Voltage [V]"
+set format y "%.2f"
+set ytics 0.25
+set xlabel "Time [minutes]"
+set format x "%.0f"
+set y2label "Capacity [mAh]"
+set y2tics border
+set grid y
+
+# extract the 'time' cell for xtics
+stats datafile every ::::0 using 3 nooutput
+time = int(STATS_min)
+
+if (time <= 120) set xtics 0.5 nomirror;
+if (time <= 300) set xtics 1 nomirror;
+if (time <= 900) set xtics 2 nomirror;
+if (time <= 1200) set xtics 3 nomirror;
+if (time <= 1800) set xtics 5 nomirror;
+if (time > 1800) set xtics 10 nomirror;
+
+# Draw the plot based on log-plotter's variable cell-count
+plot   datafile using ($3/60):($5) axes x1y1 with lines title "Voltage", \
+       datafile using ($3/60):($19) axes x1y2 with lines title "Capacity"