-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.gpi
executable file
·44 lines (35 loc) · 1.47 KB
/
plot.gpi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /usr/bin/env gnuplot
`curl 'https://docs.google.com/spreadsheets/d/1rgUTX_90dFgdIWYj5lfooY2q8WEZfxmD6D78DsB6sew/export?exportFormat=csv' > glucose.csv`
upperbound = 120
lowerbound = 80
two_days_ago = "`date '+%Y-%m-%d' --date='2 days ago'` 00:00"
tomorrow = "`date '+%Y-%m-%d' --date='tomorrow'` 00:00"
first_date = "2019-03-12 00:00"
now = "`date '+%Y-%m-%d %H:%M:%S'`"
set terminal pngcairo size 30000,1000 enhanced background rgb "#ffffff" font 'Arial,16'
set title 'Glucose Levels - All time'
set output 'all_time.png'
set timefmt '%Y-%m-%d %H:%M'
set xdata time
set xtics timedate
set xtics first_date,86400,now
set xrange [first_date:tomorrow]
set format x "%b %d"
set datafile separator ","
set xlabel "Date Time"
set ylabel "Glucose Level"
set grid
set style line 1 \
linecolor rgb '#0060ad' \
linetype 1 linewidth 2 \
pointtype 7 pointsize 1.5
plot 'glucose.csv' using 1:2:(upperbound) with filledcurves above lt rgb "#e5d229" title "hyperglycemia", \
'' using 1:2:(lowerbound) with filledcurves below lt rgb "#ce0048" title "hypoglycemia", \
'' using 1:2 with linespoints linestyle 1 title "glucose level", \
'' using 1:2:(sprintf("%d", $2)) with labels point pt 7 offset char 1,1 notitle
set title 'Glucose Levels - Last 3 days'
set output '3_days_from_next_midnight.png'
set terminal pngcairo size 1920,1080 enhanced background rgb "#ffffff" font 'Arial,16'
set xrange [two_days_ago:tomorrow]
replot
`rm glucose.csv`