gnuplot:如何用聚集的堆叠直方图将总和放在钢筋上方
多亏了这个问题 gnuplot rowStacked直方图:如何将总和放在bars上 及其答案,我学会了如何添加在其条形上方堆叠直方图。但是,我不知道如何使用聚集的堆叠直方图实现此目标。如下代码所示,我可以获得似乎放置在正确y坐标处的总和。
不幸的是,我不知道如何更改第二和第三个簇的X坐标,因此它们最终与第一个群集的总标签重叠。我需要做什么才能更改总和的X坐标,以便它们出现在正确的条上?
set term png size 1200, 500
set output "graph.png"
set datafile separator ","
set boxwidth 0.5
set style fill solid
set style data histograms
set style histogram rowstack
set offset -1.3,-0.3,100,0
set yrange [*:*] noextend
set xrange [*:*] noextend
set key outside
set key right top
set ylabel "Time (ms)"
set xtics font ", 10"
plot newhistogram at 0, "a.csv" u 2:xtic(1) t "Download" lc 1, \
'' u 3:xtic(1) t "Transfer" lc 2, \
'' u 4:xtic(1) t "Return" lc 3, \
'' u 5:xtic(1) t "Processing" lc 4, \
'' u 6:xtic(1) t "Wait" lc 5, \
'' u 7:xtic(1) t "Overhead" lc 6, \
'' u 0:($2+$3+$4+$5+$6+$7):(sprintf('%d', $2+$3+$4+$5+$6+$7)) not with labels offset 0,0.7, \
newhistogram at 3, "b.csv" u 2:xtic(1) t "" lc 1,\
for [i=3:7] '' u i:xtic(1) t "" lc (i - 1), \
'' u 0:($2+$3+$4+$5+$6+$7):(sprintf('%d', $2+$3+$4+$5+$6+$7)) not with labels offset 0,0.7, \
newhistogram at 6, "c.csv" u 2:xtic(1) t "" lc 1,\
for [i=3:7] '' u i:xtic(1) t "" lc (i - 1), \
'' u 0:($2+$3+$4+$5+$6+$7):(sprintf('%d', $2+$3+$4+$5+$6+$7)) not with labels offset 0,0.7
数据文件:
a.csv
设备,下载,传输,返回,处理,等待,开销 查找X2 Pro,350,0,0,287,1,24 OnePlus 8,350,29,19,410,30,138
b.csv
设备,下载,传输,返回,处理,等待,开销 查找X2 Pro,350,0,0,293,1,26 像素6,350,81,21,216,100,228
c.csv
设备,下载,传输,返回,处理,等待,开销 像素6,350,0,0,436,2,43 像素3,350,140,46,187,52,206
Thanks to the question gnuplot rowstacked histogram: how to put sum above bars and its answer, I learned how to add the sum of stacked histograms above their bars. However, I can't figure out how to achieve this with stacked histograms that are clustered. As shown in the below code, I can get the sum which seem to be placed at the right y coordinates.
Unfortunately, I don't know how to change the x coordinates for the second and third clusters, so they end up overlapping the first cluster's sum labels. What do I need to do to change the x coordinates of the sums so that they appear over the correct bars?
set term png size 1200, 500
set output "graph.png"
set datafile separator ","
set boxwidth 0.5
set style fill solid
set style data histograms
set style histogram rowstack
set offset -1.3,-0.3,100,0
set yrange [*:*] noextend
set xrange [*:*] noextend
set key outside
set key right top
set ylabel "Time (ms)"
set xtics font ", 10"
plot newhistogram at 0, "a.csv" u 2:xtic(1) t "Download" lc 1, \
'' u 3:xtic(1) t "Transfer" lc 2, \
'' u 4:xtic(1) t "Return" lc 3, \
'' u 5:xtic(1) t "Processing" lc 4, \
'' u 6:xtic(1) t "Wait" lc 5, \
'' u 7:xtic(1) t "Overhead" lc 6, \
'' u 0:($2+$3+$4+$5+$6+$7):(sprintf('%d', $2+$3+$4+$5+$6+$7)) not with labels offset 0,0.7, \
newhistogram at 3, "b.csv" u 2:xtic(1) t "" lc 1,\
for [i=3:7] '' u i:xtic(1) t "" lc (i - 1), \
'' u 0:($2+$3+$4+$5+$6+$7):(sprintf('%d', $2+$3+$4+$5+$6+$7)) not with labels offset 0,0.7, \
newhistogram at 6, "c.csv" u 2:xtic(1) t "" lc 1,\
for [i=3:7] '' u i:xtic(1) t "" lc (i - 1), \
'' u 0:($2+$3+$4+$5+$6+$7):(sprintf('%d', $2+$3+$4+$5+$6+$7)) not with labels offset 0,0.7
Data files:
a.csv
Device,Download,Transfer,Return,Processing,Wait,Overhead Find X2 Pro,350,0,0,287,1,24 OnePlus 8,350,29,19,410,30,138
b.csv
Device,Download,Transfer,Return,Processing,Wait,Overhead Find X2 Pro,350,0,0,293,1,26 Pixel 6,350,81,21,216,100,228
c.csv
Device,Download,Transfer,Return,Processing,Wait,Overhead Pixel 6,350,0,0,436,2,43 Pixel 3,350,140,46,187,52,206
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这里,我试图清理并简化您的脚本。我将数据包含在Datablocks中,因此仅复制&糊&跑步。
检查
帮助sum
,帮助Columnheader
...我希望其余的是自我解释。脚本:
结果:
Here I tried to clean up and simplify your script. I included the data as datablocks, so it is simply copy & paste & run.
Check
help sum
,help columnheader
... I hope the rest is self-explaining.Script:
Result: