我想使用 gnuplot 绘制以下两个数据文件。
timings0.log:
41420
32587
4082
4668
81
547
325
timings1.log:
41297
32393
4106
4720
75
502
266
它们表示一个软件的不同组件的时序,其中每个文件由具有不同配置的执行生成,并且文件中的每一行对应于不同的组件。我正在使用 sed 命令来提取时序文件中的特定行(遵循建议的方法here),并且能够显示仅显示某些组件的图。我想在同一个图中以堆积直方图的方式显示两组时序。
这是我目前的代码:
set terminal svg size 500,500 enhanced font 'Times-Roman,14'
set key vertical maxrows 3
set style data histograms
set style histogram rowstacked title offset 0,-1 gap 1
set boxwidth 0.5 relative
set style fill solid 1.0
set xlabel offset 0,1
set xrange [-1:2]
set xtics 0,1
set xtics add ("1st Config"0)
set xtics add ("2nd Config"1)
set xtics add (""2)
set yrange [0:50000]
set ylabel "Time (ms)"
set ytics 0,5000,50000
set output "test.svg"
plot newhistogram "0" lt 1, "<(sed '2!d' timings0.log)" notitle, "<(sed '3!d' timings0.log)" notitle, "<(sed '4!d' timings0.log)" notitle, "<(sed '5!d' timings0.log)" notitle,\
newhistogram "1" lt 1, "<(sed '2!d' timings1.log)" t "Load", "<(sed '3!d' timings1.log)" t "Sort", "<(sed '4!d' timings1.log)" t "Calculation", "<(sed '5!d' timings1.log)" t "Cleanup"
当我只显示一个直方图(例如对应于 timings0.log )时,代码工作正常,但是当运行上面的脚本来显示两个直方图时,它们无法展开xaxis和它们似乎重叠。以下是上述脚本的输出:
可能有一个明显的解决方案,但经过多次尝试并搜索在线提供的多种资源后,我无法获得正确的输出。我正在使用gnuplot 5 patchlevel 3。
提前致谢,非常感谢任何帮助!
答案 0 :(得分:6)
尝试at
:
plot newhistogram at 0 lt 1, ...
newhistogram at 1 lt 1, ...
我也遇到gap
的错误,至少在gnuplot 4.6中。它对rowstacked
没有影响,但您可以在 offset
之前使用。整体代码:
set terminal svg size 500,500 enhanced font 'Times-Roman,14'
set key vertical maxrows 3
set style data histograms
set style histogram rowstacked
set boxwidth 0.5 relative
set style fill solid 1.0
set xlabel offset 0,1
set xrange [-1:2]
set xtics 0,1
set xtics add ("1st Config"0)
set xtics add ("2nd Config"1)
set xtics add (""2)
set yrange [0:50000]
set ylabel "Time (ms)"
set ytics 0,5000,50000
set output "test.svg"
plot newhistogram at 0 lt 1, "<(sed '2!d' timings0.log)" notitle, "<(sed '3!d' timings0.log)" notitle, "<(sed '4!d' timings0.log)" notitle, "<(sed '5!d' timings0.log)" notitle,\
newhistogram at 1 lt 1, "<(sed '2!d' timings1.log)" t "Load", "<(sed '3!d' timings1.log)" t "Sort", "<(sed '4!d' timings1.log)" t "Calculation", "<(sed '5!d' timings1.log)" t "Cleanup"
对我来说是这样的: