gnuplot rowstacked 直方图 - 不要显示每个 xtic

gnuplot rowstacked histogram - don't show every xtic

我有一个包含 lot 行的数据文件 - 它是 CPU 用法(分解为 %user、%system、%iowait 和 %nice)在 24 小时内每 5 秒采样一次,因此总共有 17280 个样本。我的输入文件如下所示:

Time              CPU     %user     %nice   %system   %iowait    %steal     %idle
17:11:05          all      4.46      0.00      0.57      0.79      0.00     94.18
17:11:10          all      2.34      0.00      0.31      0.44      0.00     96.91
17:11:15          all      2.48      0.00      0.33      0.14      0.00     97.06

为了尝试查看何时出现高 CPU 负载,我想绘制随时间变化的非空闲 CPU 使用情况作为直方图,我使用的是这样的东西:

set key autotitle columnhead
set style data histogram
set style histogram rowstacked
set style fill solid border -1
set boxwidth 1.0
plot 'sarout.csv' using "%user":xtic(1), '' using "%system", '' using "%iowait", '' using "%nice"

麻烦的是,这在每一列上都给我一个 xtic(即时间),这是不可读的。

有没有办法让 xtic 只在整点出现?即当时间字符串匹配“*:00:00”时。

Gnuplot 直方图没有传统的数值轴。您可以在 xtic 中放置一个条件,但这只会影响抽动标签,而不影响抽动。

要获得正常的数值轴,您必须绘制 with boxes,但这不允许您堆叠值。或者你绘制并堆叠 with boxxyerrorbars:

set key autotitle columnhead
set style fill solid border -1
set xdata time
set timefmt '%H:%M:%S'
set format x '%H'
set xtics 360

plot 'sarout.csv' using 1:(0.5*column("%user")):(60):"%user" with boxxyerrorbars, \
        '' using 1:(column("%user")+0.5*column("%system")):(60):"%system" with boxxyerrorbars,\
        '' using 1:(column("%user")+column("%system")+0.5*column("%iowait")):(60):"%iowait" with boxxyerrorbars, \
        '' using 1:(column("%user")+column("%system")+column("%iowait")+0.5*column("%nice")):(60):"%nice" with boxxyerrorbars

这写起来很冗长,但可以让您最好地控制抽动。我目前无法测试此代码,但它应该可以工作。