【问题标题】:Plot time data without gaps before and after data绘制数据前后没有间隙的时间数据
【发布时间】:2014-10-16 09:34:03
【问题描述】:

我有来自监控的 CPU 利用率数据。监控不会在分钟的第一秒开始,但 Gnuplot 在这一分钟开始时开始 X 轴的值。缺失的秒数充满了空白(数据图之前和之后)。

是否能够以我的数据开始 X 轴并且没有间隙?

我不能使用:set xrange [ "13:12:24.8" : "13:21:24.8" ] 与监控时间范围的第一个和最后一个值。因为我一天要监控很多次。我希望每 1 或 2 分钟在图表中显示一次网格。

我的数据:

column 1  ... col 195 
13:12:24.8   0.78061899
13:12:25.8   5.969546498
13:12:26.8   17.21257881
...
13:21:24.8   6.922475345

gnuplot 脚本:

!/usr/bin/gnuplot
set terminal png size 1280,800
set output "CPU.png"
set title "CPU"
set xlabel "time"
set ylabel "%"
set xdata time
set timefmt "%H:%M:%S"
set format x "%H:%M:%S"
set format y "%10.0f"
set yrange [ 1 : 100 ]
set grid

#source file and collumns for axes x,y
#CPU collumns: User Time: 196 ; Proccessor Time: 195

plot "perfmon.txt" using 1:196 title "User Time" with lines, \
"perfmon.txt" using 1:195 title "Processor Time" with lines

显示差距的图表:

【问题讨论】:

    标签: time gnuplot


    【解决方案1】:

    这些“间隙”是由 gnuplot 将轴范围扩展到下一个完整 tic 的默认行为引起的。要避免 x 轴出现这种情况,请使用

    set autoscale xfix
    

    【讨论】:

    • 谢谢克里斯托夫。它确实消除了差距。但它现在是否能够在轴 X 的开头显示第一个时间值,并且每隔一分钟显示另一个值? [链接]dropbox.com/s/0scoifmlagce9cu/CPU2.png?dl=0
    • 这不能自动完成。您可以使用 set xtics add ("13:12:24.8") 手动添加此 tic,但这又需要您知道第一次值。
    猜你喜欢
    • 1970-01-01
    • 2018-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    • 2014-10-11
    • 1970-01-01
    • 2019-07-31
    相关资源
    最近更新 更多