gpt4 book ai didi

date - x 轴上的 Gnuplot 日期/时间

转载 作者:行者123 更新时间:2023-12-03 08:02:16 24 4
gpt4 key购买 nike

我有一个关于 GNUPLOT 中 x 轴上的日期和时间的快速问题。我会让代码来说话:

这是我的数据:

#Time   Data in Data out
"2013-07-22 15:59:00" 6286 3730
"2013-07-22 15:58:00" 10695 14589
"2013-07-22 15:57:00" 17868 26464
"2013-07-22 15:56:00" 18880 34012
"2013-07-22 15:55:00" 19206 41192
"2013-07-22 15:54:00" 20365 43218
"2013-07-22 15:53:00" 18459 39298
"2013-07-22 15:52:00" 3420 4686
"2013-07-22 15:51:00" 3256 4942

这是生成图形的代码:
gnuplot> set title "Data usage over the last 24 hours"
gnuplot> unset multiplot
gnuplot> set xdata time
gnuplot> set style data lines
gnuplot> set term png
Terminal type set to 'png'
Options are 'nocrop font "arial,12" fontscale 1.0 size 640,480 '
gnuplot> set timefmt "%Y-%m-%d %H:%M:%S"
gnuplot> set format x "%m-%d\n%H:%M"
gnuplot> set xlabel "Time"
gnuplot> set ylabel "Traffic"
gnuplot> set autoscale y
gnuplot> set xrange ["2013-07-21 16:00":"2013-07-22 16:00"]
gnuplot> set output "datausage.png"
gnuplot> plot "C:\\Users\\blah\\Desktop\\plot.tmp" using 1:2 t "inbound" w lines, "C:\\Users\\blah\\Desktop\\plot.tmp" u 1:3 t "outbound" w lines
^
all points y value undefined!

问题是中间的空格 datetime在 x 轴上?如果没有,您认为可能是什么问题?

最佳答案

Gnuplot 实际上并不希望时间数据用引号引起来,所以你必须告诉它:

set timefmt '"%Y-%m-%d %H:%M:%S"'

您可以像我在这里所做的那样将双引号放在单引号内,或者转义引号:
set timefmt "\"%Y-%m-%d %H:%M:%S\""

这同样适用于您的 xrange规范:
set xrange ['"2013-07-21 16:00"':'"2013-07-22 16:00"']

如果删除数据文件中的引号,则可以使用原来的格式,但列号将移动 1,因为日期占据两列而没有引号。

关于date - x 轴上的 Gnuplot 日期/时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17791828/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com