【发布时间】:2017-09-25 05:34:27
【问题描述】:
这是太阳强度的数据记录器输出。
以下是数据的摘录:
2017-09-24 12:44:48 1440
2017-09-24 12:45:49 1434
2017-09-24 12:46:50 1445
2017-09-24 12:47:51 1446
2017-09-24 12:48:52 1434
2017-09-24 12:49:53 1431
此图显示在 xterm 中,看起来很完美:
由该程序生成:
set title "OUTSIDE Light Intensity"
set xlabel "Time"
set ylabel "LUX"
set yrange [0:*]
set grid
unset mouse
unset log
set key top left
set timestamp
set xdata time
set timefmt '%H:%M:%S'
set xtics format '%H:%M'
set terminal x11
set datafile missing "0.00"
plot 1750 lw 1 lc rgb 'black' t "South", \
"today.dat" using 2:($3*1.5) with lines lw 1 lc rgb 'red' t "Lux"
pause 30
reread
根据
How can you watch gnuplot realtime data plots as a live graph, with automatic updates?
到目前为止,一切都很好。
在 cron 中运行的 gnuplot 程序会生成等效的 .png 文件。除了输出文件的终端设置和规格外,其他都是一样的:
set output "plux.png"
set terminal pngcairo
plot 1750 lw 2 lc rgb 'black' t "South", \
"today.dat" using 2:($3*1.5) with lines lw 2 lc rgb 'red' t "Lux"
输出如下所示:
所以我的问题是:如何控制 .png 图,使其看起来与 x11 终端中的一样?
似乎与字体有关。
本文与之对话:
摘录:
Gnuplot 不提供任何自己的字体。它依赖于外部字体处理,不幸的是,其细节因终端类型而异。
【问题讨论】:
-
使用
wxt和pngcairo,stackoverflow.com/a/30334657/260421 -
这很酷。但这会以我总是运行实时图表为前提。我选择让 cron 全天间隔生成 png 文件,直到午夜运行 eod(一天结束)python 脚本以归档从各地的各种 Rpi/Nano 传感器收集的所有内容,并按日期命名。这样我就可以去野营旅行,它仍然会在无人看管的情况下自行运行,将其全部保存到磁盘以防止 SD 卡或闪存驱动器故障(其中有一些)。所以 png 生成程序与实时绘图程序是分开的。