Pet*_*erM 5 python precision gnuplot
目前我正在使用gnuplot根据时间线绘制数据.然而,时间线的精度以毫秒为单位,但gnuplot似乎只能处理秒数.
我已经看了几个替代方案,但实际上我只需要像gnuplot这样可以应对一小段时间的东西.
用于主脚本的编程语言是Python,虽然我看过matplotlib,但它似乎比gnuplot更加"重型".因为我不会总是更新图形方面的东西,所以我希望尽可能简单.
有什么建议?
更新
我正在使用gnuplot:
set xdata time
set timefmt "%Y-%m-%d-%H:%M:%S"
Run Code Online (Sandbox Code Playgroud)
但是没有%f可以获得毫秒.例如,这有效:
2011-01-01-09:00:01
Run Code Online (Sandbox Code Playgroud)
但是我需要:
2011-01-01-09:00:01.123456
Run Code Online (Sandbox Code Playgroud)
PP.*_*PP. 14
根据gnuplot 4.6手册,它在"时间/日期说明符"(gnuplot 4.6 PDF的第114页)下说明:
%S - 秒,输出上的整数0-60,输入上的(双)
这意味着,在阅读时间戳诸如当2013-09-16 09:56:59.412小数部分将被包括作为部分%S说明符.这样的时间戳将正确处理:
set timefmt "%Y-%m-%d %H:%M:%S"
set datafile separator ","
plot "timed_results.data" using 1:2 title 'Results' with lines
Run Code Online (Sandbox Code Playgroud)
并提供如下数据:
2013-09-16 09:56:53.405,10.947
2013-09-16 09:56:54.392,10.827
2013-09-16 09:56:55.400,10.589
2013-09-16 09:56:56.394,9.913
2013-09-16 09:56:58.050,11.04
Run Code Online (Sandbox Code Playgroud)
Eri*_*got 10
您可以设置刻度线格式
set format x '%.6f'
Run Code Online (Sandbox Code Playgroud)
或者(也许,我没有尝试过,因为我现在更喜欢使用Matplotlib并且我的机器上没有安装gnuplot):
set timefmt "%Y-%m-%d-%H:%M:%.6S"
Run Code Online (Sandbox Code Playgroud)
(注意与%S格式字符串一起指定的位数).
更多细节可以在优秀的不那么常见问题中找到.
| 归档时间: |
|
| 查看次数: |
10615 次 |
| 最近记录: |