【问题标题】:Incorrect values when plotting from file containing time data - gnuplot从包含时间数据的文件中绘图时值不正确 - gnuplot
【发布时间】:2014-03-18 15:01:46
【问题描述】:

我正在尝试使用 gnuplot 生成图表,但它似乎没有显示正确的值: 数据是:

03/18/2014 15:00:50                32,4
03/18/2014 14:00:48                32,4
03/18/2014 13:00:48               32,42
03/18/2014 12:00:44                32,4
03/18/2014 11:00:42                122,2
03/18/2014 10:00:47                22,4
03/18/2014 09:00:37                53,9
03/18/2014 08:00:35                14,2

sh 是:

#!/usr/bin/gnuplot

set title "Plot x^2"
set terminal png
set output "output.png"

set xlabel "X"
set ylabel "Y"
#set datafile sep ','
set xdata time
set timefmt '%m/%d/%Y %H:%M:%S'
plot 'pepe.csv' using 1:2 with lines

它告诉我:

【问题讨论】:

  • 您希望它是什么样的?具体一点。
  • 谢谢。我希望该行具有第二个值 (32,4-32,4-32,42-32,4-28,7-23-6).... X asys 很好,但第二个值不要t 显示正确的值
  • 我不是这些数字的来源,是一列减去另一列吗?您可以编辑问题以使其更清晰吗?
  • 我编辑数据。该图只是表空间大小的时间图。谢谢
  • 看起来 gnuplot 在解析两列数据时遇到了问题。应用设置 set decimalsign ',' 可能会有所帮助。

标签: gnuplot


【解决方案1】:

@andyras 对set decimalsign ',' 的建议很有帮助,但如果您在时间格式中有空格,则它被视为多列。引用文档:

timedata 中的每组非空白字符在 using n:n 规范中计为一列。因此 11:11 25/12/76 21.0 由三列组成。为避免混淆,如果您的文件包含时间数据,gnuplot 要求您提供完整的使用规范。

这意味着您需要将using 1:2 更改为using 1:3

使用您的原始数据,此脚本适用于我:

#!/usr/bin/gnuplot

set title "Plot x^2"
set terminal png
set output "output.png"

set xlabel "X"
set ylabel "Y"
set decimalsign ','
set timefmt '%m/%d/%Y %H:%M:%S'
set xdata time

plot 'decimal.txt' u 1:3 with lines

输出:

或者,您可以在数据文件中使用不同的数据分隔符,例如 ,,时间将仅计为一列。为此,您需要将行 set datafile sep ',' 添加到您的脚本中。

编辑:您可能还想考虑使用pngcairo 终端(set term pngcairo),因为它看起来好多了:

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2014-07-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多