a3ea29fd2e3ddb9af48cfd09744a2c4f85ee87da
[SaveMySugar/python3-savemysugar.git] / plot / call_distance_modulation.gnuplot
1 #!/usr/bin/gnuplot -persist
2 #
3 #    
4 #       G N U P L O T
5 #       Version 5.0 patchlevel 1    last modified 2015-06-07 
6 #    
7 #       Copyright (C) 1986-1993, 1998, 2004, 2007-2015
8 #       Thomas Williams, Colin Kelley and many others
9 #    
10 #       gnuplot home:     http://www.gnuplot.info
11 #       faq, bugs, etc:   type "help FAQ"
12 #       immediate help:   type "help"  (plot window: hit 'h')
13
14 set border 1
15 set nogrid
16 set key autotitles nobox reverse Left enhanced vert left at graph 0, screen 0.98
17
18 set title "Morse code sent using phone rings and pulse-distance modulation"
19 set xlabel "time since the first call (seconds)"
20
21 set noytics
22
23 set xtics 30 out nomirror rotate by -45 font "Georgia,12"
24
25 set yrange[0:0.7]
26 set size ratio 0.3
27
28 set style arrow 1 heads size 2,90 front ls 201 lc 'gray'
29
30 _w = 1280
31 _h = _w * 0.39
32
33 # a helper function
34 min(a, b) = (a < b) ? a : b
35
36 # The data files
37 transmit_data="codex_transmit.log"
38 receive_data="codex_receive.log"
39 #transmit_data="savemysugar_transmit.log"
40 #receive_data="savemysugar_receive.log"
41
42 #transmit_data="android_codex_transmit.log"
43 #receive_data="android_codex_receive.log"
44 #transmit_data="android_savemysugar_transmit.log"
45 #receive_data="android_savemysugar_receive.log"
46
47 set terminal unknown
48
49 plot transmit_data using 1:(1)
50 sender_t0 = GPVAL_DATA_X_MIN
51
52 plot receive_data using 1:(1)
53 receiver_t0 = GPVAL_DATA_X_MIN
54
55 t0 = min(sender_t0, receiver_t0)
56
57 morse_symbol(symbol) = symbol eq " " ? "sep" : symbol eq "/" ? "SEP" : symbol
58 end_of_signal(symbol) = (symbol eq " ") || (symbol eq "/") || (symbol eq "EOM")
59 text_character(symbol, character) = symbol eq "/" ? character . "␣" : character
60
61 set terminal qt 0 enhanced font "Georgia,14" size _w,_h
62 #set terminal pngcairo notransparent  nocrop truecolor rounded enhanced font "Georgia,14" fontscale 1.0 size _w,_h
63 #set output 'pulse_distance_modulation.png'
64
65 plot \
66   transmit_data using (0):(0):($1 - t0):($1 - t0 + $8):(0):(0.5) with boxxy \
67     fs solid noborder lc "#90caf9" title 'outgoing calls', \
68   receive_data using ($1 - t0):(0.5) with impulses lw 2 lc '#ff3d00' title 'incoming rings', \
69   receive_data using ($4 > 0 ? $1 - t0 : 1/0):(0.53):(-$4):(0) with vectors arrowstyle 1 notitle, \
70   receive_data using ($4 > 0 ? ($1 - t0) - ($4 / 2) : 1/0):(0.56):(morse_symbol(strcol(6))) with labels notitle, \
71   receive_data using (end_of_signal(strcol(6)) ? ($1 - t0) : 1/0):(0.61):(text_character(strcol(6), strcol(8))) with labels font "Courier,14" notitle, \