1

我刚被诊断出患有高血压,需要 a) 现在定期检查我的血压并记录下来 b) 吃药。你无法帮助我解决 b),但我需要你的帮助来解决 a)。

我需要记录我的血压,因此我需要每天读取一些读数。我的日志如下所示:

20121001 0801 175 101
20121001 0802 Pill
20121001 1017 125 91
20121001 1537 121 101
20121001 1907 117 89
20121002 0758 191 111
20121002 0759 Pill
20121002 1003 117 98
(...)

你能帮我用一个gnuplot配置文件来读取上述两个数据点,将它们与时间(%Y%m%d %H%M)绘制出来吗?

这里需要注意的是线条“ ... Pill”,我想在情节中显示为一个点、一条垂直线或类似的东西(它们只是在我服用药丸时显示)。

另外,我不太确定这是否可能,我想可视化数据点 1 和数据点 2 之间的差异,即。175-101=74在第一行。

这将极大地帮助我想象我的药丸是否(如果是,何时)开始起作用。

谢谢!

4

2 回答 2

1

我创建了以下bash脚本。使用您的日志文件名作为参数运行它:

#! /bin/bash -e
input=$1
start=$(head -n1 "$input")
start=${start:0:9}0000
end=$(tail -n1 "$input")
end=${end:0:9}2359

gnuplot <<EOF
set terminal png
set output 'bp.png'
set xdata time
set timefmt '%Y%m%d %H%M'
set xrange ['$start':'$end']
plot '< grep -v Pill "$input"' using 1:(\$3-\$4):3:4 with errorbars pt 2 title 'Pressure', \
     '< grep    Pill "$input"' using 1:(100) with points lw 2 pt 7 title 'Pill'
EOF
(($?)) && exit 1
display bp.png
于 2012-10-05T09:20:24.443 回答
0

我将回答你问题的第二部分。因此,我更新了您的文件以记录一些内容。

 1  20121001 0801 175 101
 2  20121001 0802 Pill
 3  20121001 1017 125 91
 4  20121001 1537 121 101
 5  20121001 1907 117 89
 6  20121002 0758 191 111
 7  20121002 0759 Pill
 8  20121002 1003 117 98

gnuplot 脚本看起来像这样

plot "< grep -v Pill meas2" using 1:($4-$5) with line, \
     "< grep Pill meas2" using 1:($2*0) ps 10 pt 8

选择不包含的输入行的Pill位置。您可以使用$4-$5来执行计算。另一个图在水平轴上绘制了一个符号,表示药丸在该线上的时间。

对于第一部分,我发现了一些提示:http ://t16web.lanl.gov/Kawano/gnuplot/datetime-e.html

于 2012-10-05T09:18:31.873 回答