来自csv输入的gnuplot timefmt错误"错误的时间格式"

时间:2016-09-02 11:17:53

标签: gnuplot

我试图绘制两列500 MB的csv文件,如下所示:

ID,"timestamp"
1,"2016-02-09 14:46:52.683"
2,"2016-02-09 14:47:02.687"
3,"2016-02-09 14:47:09.896"
4,"2016-02-09 14:47:12.702"
5,"2016-02-09 14:47:22.663"
6,"2016-02-09 14:47:32.668"
7,"2016-02-09 14:47:42.68"
8,"2016-02-09 14:47:52.676"
9,"2016-02-09 14:48:02.661"

我已经写了一个gnuplot脚本,但不确定我哪里出错了。我也跟着其他帖子。我错过了什么?

我认为毫秒数据有时几毫秒的值可能是一个问题 - 但同样,我不知道如何解决。

非常感谢提前!克里斯

set datafile separator ","
set key autotitle columnhead
set xdata time
set timefmt '"%Y-%m-%d %H:%M:%.6S"'
set format x "%Y-%m-%d %H:%M:%.6S"
# set xrange ['"2016-04-01 00:00:00.000000"':'"2016-05-01 17:00:00.000000"']
plot "~/timestampi.csv" u 2:1

输出:

Terminal type set to 'qt'
gnuplot> load "~/g.p"
         "/home/chrisb/g.p", line 6: warning: Bad time format in string
         "/home/chrisb/g.p", line 6: warning: Bad time format in string
         "/home/chrisb/g.p", line 7: warning: Skipping data file with no valid points

gnuplot> plot "~/timestampi.csv" u 2:1 w l
                                          ^
         "/home/chrisb/g.p", line 7: all points y value undefined!

gnuplot> 

1 个答案:

答案 0 :(得分:1)

仅对tic标签支持指定显式的第二个精度。解析输入数据时,秒总是被解析为浮点数:

%.6S

请注意,将set format-- Cycle with respect to whitespace (currently only spaces). -- Given a source string and its length, and a longer target string -- (which may contain spaces) match the source to target such that: -- 1. both will have the same length -- 2. spaces in the target string will remain spaces -- 3. chars from the source string will be cycled -- -- Example: -- src: "ALLY", len: 4 -- target: "MEET AT DAWN" -- Result: "ALLY AL LYAL" cycleWS :: String -> String -> String cycleWS = align . cycle -- Align with respect to spaces. -- Given two strings, source and target, align the source to target such that: -- 1. both will have the same length -- 2. spaces in the target string will remain spaces -- Assume the source string is long enough align :: String -> String -> String align [] _ = [] align _ [] = [] align (x:xs) (y:ys) = if isSpace y then y : align (x:xs) ys else x : align xs ys 一起使用会有效,但没有意义,因为如此大的时间范围,您将无法获得一秒钟的小数。