gnuplot为什么警告:字符串中的时间格式错误 [英] gnuplot why warning: Bad time format in string

查看:44
本文介绍了gnuplot为什么警告:字符串中的时间格式错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好和gnuplot新年快乐的用户,我的数据存储如下:

Hello and Happy new year gnuplot's users, I have my data store like this :

France,FRA,Europe,67012883,cases,0,2020-01,,0,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,0,2020-02,0,0,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,0,2020-03,0,0,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,3,2020-04,0.00447675113455423,3,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,3,2020-05,0.00895350226910846,6,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,5,2020-06,0.011938003025478,11,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,1,2020-07,0.00895350226910846,12,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,0,2020-08,0.00149225037818474,12,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,118,2020-09,0.1760855446258,130,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,996,2020-10,1.66236692129781,1126,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,4297,2020-11,7.89848125173185,5423,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,10595,2020-12,22.2225926319272,16018,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,24156,2020-13,51.857192892298,40174,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,30304,2020-14,81.2679555959412,70478,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,24925,2020-15,82.4154961367652,95403,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,17203,2020-16,62.8655239321669,112606,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,11969,2020-17,43.5319280324053,124575,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,6712,2020-18,27.8767293148692,131287,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,7776,2020-19,21.6197234791406,139063,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,3348,2020-20,16.5997932069271,142411,"Epidemic intelligence, national weekly data"
France,FRA,Europe,67012883,cases,2510,2020-21,8.74160271540623,144921,"Epidemic intelligence, national weekly data"

我的脚本:

reset
set terminal pngcairo size 800,600
set output 'test.png'
set datafile separator ","
set xdata time
set timefmt "%Y-%W"
#set format x "%s" timedate
set xtics format "%s" 
set grid

plot '<grep cases |grep France data1.csv' u 7:6 t 'Nbre cases France' w l lw 1

错误:

France,FRA,Europe,67012883,deaths,2638,2020-51,80.4919853992851,60549,"Epidem...
<grep cases |grep France data1.csv:102:"covid.gnu", line 11: warning: Bad time format in string

为什么会有此错误消息?而且我被困住了,我的数据没有绘制出来.

Why do I have this error message ? and I'm stuck, my data aren't plotted.

推荐答案

我看到两个问题.

  1. 输入时将忽略时间格式'%W'.请参阅内部文档帮助time_specifiers .如果您想将其解释为"N周第一天的第一秒",您必须自己进行计算,因为gnuplot不会为您这样做.

  1. The time format '%W' is ignored on input. See the internal documentation help time_specifiers. If you want to interpret it as something like "first second of the first day of week N" you would have to do that calculation yourself since gnuplot doesn't do this for you.

shell命令 grep cases | grep France data1.csv 格式错误.如果将其替换为 grep France data1.csv ,该程序将无错误执行,但是由于问题(1),由于第#周丢失,它不会生成您可能想要的绘图.

The shell command grep cases |grep France data1.csv is mal-formed. If you replace this with grep France data1.csv the program will execute without error, but due to problem (1) it will not produce the plot you probably want since the week # is lost.

这是更正版本的起点:

set datafile separator ","
set xdata time
timefmt = "%Y-%W"
set xtics time format timefmt
set grid

SECPERWEEK = 3600.*24.*7.
Y_W(col) = timecolumn(col,timefmt) + SECPERWEEK * (strcol(col)[6:7] - 1)

plot 'data1.csv' u (Y_W(7)):6 t 'Nbre cases France' w l lw 1

这篇关于gnuplot为什么警告:字符串中的时间格式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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