Gnuplot日期/时间在x轴 [英] Gnuplot date/time in x axis

查看:529
本文介绍了Gnuplot日期/时间在x轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



这是我的数据:

  #Time数据输出
2013-07-22 15:59:006286 3730
2013-07-22 15:58:0010695 14589
2013-07-22 15:57:0017868 26464
2013-07-22 15:56:0018880 34012
2013-07-22 15:55:0019206 41192
2013-07-22 15:54:0020365 43218
2013-07-22 15:53:0018459 39298
2013-07-22 15:52: 003420 4686
2013-07-22 15:51:003256 4942

这是生成图形的代码:

  gnuplot>设置标题过去24小时内的数据使用
gnuplot> unset multiplot
gnuplot>设置xdata时间
gnuplot>设置样式数据行
gnuplot>设置术语png
终端类型设置为'png'
选项是'nocrop字体'arial,12字体大小1.0大小640,480'
gnuplot> set timefmt%Y-%m-%d%H:%M:%S
gnuplot>设置格式x%m-%d\\\
%H:%M
gnuplot>设置xlabelTime
gnuplot> set ylabelTraffic
gnuplot>设置自动缩放y
gnuplot> set xrange [2013-07-21 16:00:2013-07-22 16:00]
gnuplot>设置输出datausage.png
gnuplot>绘制C:\\\\\blah\\Desktop\\\\plot.tmp,使用1:2 tinboundw行,C:\\Users\\呃嗯\\ k k u u u u u u u u u u u u u u lines lines lines lines lines lines lines lines lines lines lines lines

问题是 date之间的空格时间在x轴?如果没有,你认为可能是什么问题?



谢谢你的时间。




Jose

解决方案

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,因为日期占用了两列而没有引号。


I have a quick question regarding dates and times in x-axis in GNUPLOT. I'll let the code do the talking:

This is my data:

#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

And this is the code that is generating the graph:

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!

Is the problem the space in between date and time in the x-axis? If not, what do you think could be the problem?

Thank you for your time.

Best regards, Jose

解决方案

Gnuplot doesn't actually expect time data to be in quotes, so you have to tell it:

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

You can put the double quotes inside single quotes as I did here, or escape the quotes:

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

the same applies to your xrange specification:

set xrange ['"2013-07-21 16:00"':'"2013-07-22 16:00"']

If you delete the quotes in the data file, then you can use the formatting you originally had, except the column numbers will be shifted over by 1 since the date takes up two columns without the quotes.

这篇关于Gnuplot日期/时间在x轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆