docs
[mirrors/Programs.git] / sleepplot.sh
... / ...
CommitLineData
1#!/bin/bash
2
3test -z "$1" && {
4 echo "Usage: $0 sleeplog.txt"
5 exit 23
6}
7
8#Count events:
9seconds=60
10./sleepcount.sh "$1" "$seconds"
11
12#Approximate size of graph
13size="$(tail -n 1 "$1" | cut -d . -f 1)"
14test $size -gt 3600 && size="$(( $size/10 ))" #For prolonged periods
15size="$(( 600 + $size ))"
16
17#Plot it
18gnuplot << EOF
19set output "$1.png"
20set terminal png size $size,300
21
22set title "Sleep motions"
23set xlabel "time"
24set ylabel "motion"
25
26set yrange [-0.5:3]
27
28set xdata time
29set timefmt "%s"
30#set format x "%H:%M:%S"
31
32set grid
33
34#set pointsize 0.5
35plot "$1" using 2:5 title "Sensor state" with steps,\
36"$1.counts.$seconds" using 1:(\$2/5) title "Activations in last $seconds seconds" smooth csplines
37
38EOF
39
40
41
42
This page took 0.134752 seconds and 5 git commands to generate.