【问题标题】:Gnuplot: x-axis narrow label spacing in timeseries plotGnuplot:时间序列图中的 x 轴窄标签间距
【发布时间】:2014-03-06 09:23:34
【问题描述】:

Gnuplot 往往会使时间序列图中的 x 轴混乱。有关窄间距标签的示例,请参见下图:

有没有办法让 gnuplot 避免如此狭窄的间距?最好这应该在 gnuplot 脚本中完成以生成绘图。

我使用以下 gnuplot 脚本和一个随机数据文件生成了绘图:

set terminal png
set output "plot.png"

set timefmt "%s"
set xdata time

set xlabel "time"
set ylabel "Random Data"

set boxwidth 600
set style fill solid 0.5

set key below

plot "random.dat" using 1:2 w boxes title ".60"

注意:我使用的是 Gnuplot 4.6。

编辑

  1. 写更少的时间就足够了。
  2. 生成绘图的示例文件可在http://pastebin.com/w0kia7Dt 获得

【问题讨论】:

  • 你想把x轴展开,还是写少一点?
  • 我想写的次数越少越好。
  • 您能否提供指向您的数据文件的链接(可能在 pastebin 或类似的东西上)?
  • 您似乎找到了答案,但这个问题 (stackoverflow.com/questions/15975631/…) 可能会提供一些避免重叠的方法。

标签: gnuplot time-series


【解决方案1】:

您可以使用set xtics 在 x 轴上标记更少的点。第一个和最后一个参数的格式必须与您的时间相同,在您的情况下为 %s,或自 UNIX 纪元以来的秒数。中间的参数是秒数。

例如,要每 8 小时标记一次,而不是上面的每 4 小时标记一次,您可以执行以下操作:

hours = 8
start = "1393934400"
end = "1394107200"
set xtics start, hours * 3600, end

您可以在终端中使用date 命令获取这些开始值和结束值

date -d "2014-03-04 08:00" +%s

您也可以使用 gnuplot system 命令将它们添加到您的脚本中

end = system("date -d '2014-03-06 12:00' +%s")

详情请见help set xtics time_axis

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-12
    • 2017-01-17
    • 2022-07-05
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多