From f0959aef09cc1aafb6de27a3dd8cca084512dc4a Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Mon, 5 Oct 2020 18:46:31 +0200 Subject: [PATCH] graph data from postgresql using gnuplot --- gnuplot/Makefile | 2 ++ gnuplot/axes.gnuplot | 27 +++++++++++++++++++++++++++ gnuplot/axes.sql | 2 ++ 3 files changed, 31 insertions(+) create mode 100644 gnuplot/Makefile create mode 100644 gnuplot/axes.gnuplot create mode 100644 gnuplot/axes.sql diff --git a/gnuplot/Makefile b/gnuplot/Makefile new file mode 100644 index 0000000..f857771 --- /dev/null +++ b/gnuplot/Makefile @@ -0,0 +1,2 @@ +all: + psql -A -F "," -t zc < axes.sql | tee axes.txt diff --git a/gnuplot/axes.gnuplot b/gnuplot/axes.gnuplot new file mode 100644 index 0000000..a8fb8d9 --- /dev/null +++ b/gnuplot/axes.gnuplot @@ -0,0 +1,27 @@ +set terminal pngcairo color size 800,600 +#set output 'axes.png' +set output + +set xdata time +set timefmt "%Y-%m-%d %H:%M:%S" + +set datafile separator "," + +#unset border +#set key outside +#set key top left horizontal + +set grid +set key left + +set format x "%H:%M" + +set multiplot +set size 1,0.5 +set origin 0, 0.5 + +plot "axes.txt" using 1:2 with lines title "X angle" + + +set origin 0, 0 +plot "axes.txt" using 1:3 with lines title "Y angle" diff --git a/gnuplot/axes.sql b/gnuplot/axes.sql new file mode 100644 index 0000000..11522de --- /dev/null +++ b/gnuplot/axes.sql @@ -0,0 +1,2 @@ +select to_char(time, 'YYYY-MM-DD HH24:MI:SS'), x_axis_angle, y_axis_angle from zc where time > now() - interval '6 hours' order by time asc + -- 2.20.1