【问题标题】:gnuplot multiple lines with Time on X axisgnuplot 多行与 X 轴上的时间
【发布时间】:2013-08-08 04:57:28
【问题描述】:

我查看了问题,但仍然无法正常工作。

我的数据集是这样的:

[date] , [%cpu] , [mem]
23:00:39 , 21.9 , 2.1
23:00:44 , 21.8 , 2.1
23:00:49 , 21.8 , 2.1
23:00:54 , 21.8 , 2.1
23:00:59 , 21.7 , 2.1

我的 Gnuplot 语句(刚开始用于此数据)是:

set timefmt "%H:%m:%s"
set xdata time
set datafile sep ','
plot '/tmp/info' using 2 title 'cpu' with lines, '/tmp/info' using 3 title 'memory%' with lines

我收到以下错误:

    Need full using spec for x time data

我已经尝试过 autoscale x ,但我有点迷茫,任何帮助将不胜感激。

【问题讨论】:

    标签: gnuplot


    【解决方案1】:

    时间数据要求您始终指定要使用的所有列。 (另请注意更正后的timefmt):

    set timefmt "%H:%M:%S"
    set xdata time
    set datafile sep ','
    set style data lines
    plot '/tmp/info' using 1:2 title 'cpu', '' using 1:3 title 'memory%'
    

    原因是timefmt 也可能包含空格,因此用于时间轴的数据可能来自两列。考虑以下修改后的数据文件:

    23:00:39 06/08/13 21.9 2.1
    23:00:44 06/08/13 21.8 2.1
    23:00:49 06/08/13 21.8 2.1
    23:00:54 06/08/13 21.8 2.1
    23:00:59 06/08/13 21.7 2.1
    

    这种格式的绘图命令是:

    set timefmt "%H:%M:%S %d/%m/%Y"
    set xdata time 
    set format x "%H:%M:%S"
    set style data lines
    plot 'mydata.dat' using 1:3 t 'cpu', '' using 1:4 t 'memory%'
    

    为避免混淆,对于时间数据,绘图样式(此处为with lines)使用的所有列都需要通过using 语句明确给出。

    【讨论】:

      【解决方案2】:

      您的绘图命令看起来像这样:

      plot '/tmp/info' using 1:2 title 'cpu' with lines, '/tmp/info' using 1:3 title 'memory%' with lines
      

      【讨论】:

        【解决方案3】:

        我有一个类似的 gnuplot 问题,我有一个数据文件,例如:

        05:07:00    0.0769  0.0769  0.0000  0.0000  0.0000  0.0000  0.0000
        05:08:00    0.2308  0.2308  0.0000  0.0000  0.0000  0.0000  0.0000
        

        我尝试使用,但它无法正常工作

        set xdata time
        set timefmt "HH:MM:SS";
        plot "wed" using 0:2 t 'wtf" w lines
        

        修复是几件事,主要是在 timefmt 字符串中使用 % 并且只使用一个字母。同样使用设置格式 x 作为输出是关键(并将第一列用作 1 - 尽管我之前也尝试过)。

        这是为我工作的最小输出脚本:

        set xdata time
        set timefmt "%H:%M:%S"
        set format x "%H:%M"
        plot "wed" using 1:2 t 'my title' w lines
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2013-07-21
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-09-30
          • 1970-01-01
          • 1970-01-01
          • 2011-11-19
          相关资源
          最近更新 更多