【问题标题】:Time conversion does not work in gnuplot时间转换在 gnuplot 中不起作用
【发布时间】:2017-06-01 17:24:27
【问题描述】:

我有以下 sn-p 通过 gnuplot 输出图形。

set datafile separator ","

set title "Memory"
set xlabel "Values"
set ylabel "Date"
set ydata time
set timefmt "%H"
set format y "%d/%m/%Y"
set key left top
set grid

plot 'memory-memory-buffered_combined' using 0:2 titl "1" with lines,\
     'memory-memory-cached_combined' using 0:2 title "2" with lines
cat 
pause -1

但是,当我得到结果时,它是从 1970 年开始的。

我正在阅读的 csv 的前 5 行;

epoch,value
1478193413.596,72910
1478193473.412,134432
1478193413.158,65449
1478193411.929,60157

所以,实际上是 2016 年 11 月。

我的脚本的哪一部分应该有所不同?

【问题讨论】:

  • 当您plot .. using 0:2 时,输入文件中的行号将用于 x 轴,第二列(“值”)中的数据用于 y 轴。但是从您的标签命令看来,您希望 x 轴上的“值”和 y 轴上的“日期”(大概是第 1 列)。也许您应该改用plot .. using 2:1?此外,如果您想使用 epoch,您可能需要将 timefmt 设置为 %s(请参阅 help timefmt)。

标签: linux bash gnuplot


【解决方案1】:
set datafile separator ","

set title "irq"
set xlabel "Date"
set ylabel "Values"
set xdata time
set timefmt "%s"
set format x "%d/%m/%Y"
set key right top
set grid

set terminal jpeg size 3600,2100 enhanced font helvetica 20
set output "irq.jpg"


plot "/irq/irq-16_combined" using 1:2 title "irq-16" with lines

我对脚本进行了一些更改,但仍然不一致。在 100 个具有相同模式和具有相同列名和值的相似文件的脚本中,只有一个仍然具有从 1970 年开始的输出。你们中有人遇到过这样的问题吗?

【讨论】:

  • 我认为当它被 10k 行数据超载时会发生这种情况。当我修剪它时,它会回到所需的时间间隔。
  • 那将是令人惊讶的。我猜您的数据文件至少包含一行具有非常低的纪元值,然后将其转换为 1970 年代。 stats "filename" using 1 的输出是什么(其中 filename 是您的数据文件的名称)?
猜你喜欢
  • 1970-01-01
  • 2019-06-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-12-03
  • 1970-01-01
相关资源
最近更新 更多