plot - gnuplot 堆叠直方图重叠

标签 plot gnuplot histogram

我想使用 绘制以下两个数据文件gnuplot .

时间0.log:

41420
32587
4082
4668
81
547
325

时间1.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 上展开并且它们似乎重叠 .以下是上述脚本的输出:

enter image description here

可能有一个明显的解决方案,但经过多次尝试并搜索了多个在线可用资源后,我未能获得正确的输出。我正在使用 gnuplot 5 补丁级别 3。

提前致谢,任何帮助将不胜感激!

最佳答案

试试 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"

对我来说看起来像这样:

enter image description here

关于plot - gnuplot 堆叠直方图重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38921899/

相关文章:

matlab - 在 Matlab 图形中绘制图例

matplotlib - 将 xarray 每日数据分组为每月平均值

python - 如何使用 Matplotlib 制作具有光环效果的散点图?

linux - gnuplot 基本绘图问题

pdf - 将通过 gnuplot 生成的 tex 和 eps 文件的信息组合到单个图形文件中?

if-statement - gnuplot 中的“else if”逻辑语句

c++ - 直方图均衡不适用于彩色图像 - OpenCV

python - pyplot.hist 中的直方图条不以 xticks 为中心

r - R 生成的 PDF 具有不一致的 MD5 校验和

ios - 如何为 CoreImage 编写类似直方图的内核过滤器?