如何在每个栏中使用值标签的GNUPLOT中绘制划船堆的直方图
我想绘制划船的直方图。以下是我到目前为止所拥有的:
我使用了以下代码:
reset
set bmargin 10
set lmargin 20
set rmargin 16
set tmargin 7
show margin
set title "" font "Verdana,27"
show title
set grid
set xlabel offset 0,-5 font "Verdana,25"
set xlabel "Number of Cores"
show xlabel
set xtics font "Verdana,18"
set ylabel offset -4,0 font "Verdana,25"
set ylabel "Time (%)"
show ylabel
set yrange [0:130]
set ytics font "Verdana,18"
set ytics (0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
set style data histogram
set style histogram rowstacked title offset 0,3
set style fill solid border lt -1
set boxwidth 0.9
set key right
set key font "Verdana,17"
set key autotitle columnheader horizontal
plot newhistogram '{/=22 1-Core}', \
for [i=2:5] 'base_vs_FHA_speedup_1core.dat' using i:xtic(1), \
newhistogram '{/=22 2-Cores}' lt 1, \
for [i=2:5] 'base_vs_FHA_speedup_2core.dat' using i:xtic(1) notitle, \
newhistogram '{/=22 4-Cores}' lt 1, \
for [i=2:5] 'base_vs_FHA_speedup_4core.dat' using i:xtic(1) notitle, \
newhistogram '{/=22 8-Cores}' lt 1, \
for [i=2:5] 'base_vs_FHA_speedup_8core.dat' using i:xtic(1) notitle
我有4个不同的数据文件,带有示例数据 这种
配置Col1 col2 col3 col4 col4 col5
base_vs_fha_1core.dat
Base 5 50 40.5 4.5
FHA 5 16 38 5 1.54x
Base 9.3 47 37.3 6.3
FHA 9.3 15 34.3 6.3 1.54x
base_vs_vs_fha_2core.dat
Base 18 41 33.9 7.06
FHA 16.6 13.07 30.7 7.4 1.47x
base_vs_fha_4core.dat
Base 27.7 34.3 28.3 9.6
FHA 28.3 11.45 25.3 9.6 1.34x
喜欢 在直方图中的每个栏中都标记为相应的值和每对第二直方图顶部顶部的最后一列的值。我该如何实现?
我可以合并所有4个文件并实现相同的目标吗?
I want to draw a rowstacked histogram. The following is what I have so far:
I have used the code below:
reset
set bmargin 10
set lmargin 20
set rmargin 16
set tmargin 7
show margin
set title "" font "Verdana,27"
show title
set grid
set xlabel offset 0,-5 font "Verdana,25"
set xlabel "Number of Cores"
show xlabel
set xtics font "Verdana,18"
set ylabel offset -4,0 font "Verdana,25"
set ylabel "Time (%)"
show ylabel
set yrange [0:130]
set ytics font "Verdana,18"
set ytics (0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
set style data histogram
set style histogram rowstacked title offset 0,3
set style fill solid border lt -1
set boxwidth 0.9
set key right
set key font "Verdana,17"
set key autotitle columnheader horizontal
plot newhistogram '{/=22 1-Core}', \
for [i=2:5] 'base_vs_FHA_speedup_1core.dat' using i:xtic(1), \
newhistogram '{/=22 2-Cores}' lt 1, \
for [i=2:5] 'base_vs_FHA_speedup_2core.dat' using i:xtic(1) notitle, \
newhistogram '{/=22 4-Cores}' lt 1, \
for [i=2:5] 'base_vs_FHA_speedup_4core.dat' using i:xtic(1) notitle, \
newhistogram '{/=22 8-Cores}' lt 1, \
for [i=2:5] 'base_vs_FHA_speedup_8core.dat' using i:xtic(1) notitle
I have 4 different data files with sample data like this
Configuration col1 col2 col3 col4 col5
base_vs_FHA_1core.dat
Base 5 50 40.5 4.5
FHA 5 16 38 5 1.54x
base_vs_FHA_2core.dat
Base 9.3 47 37.3 6.3
FHA 9.3 15 34.3 6.3 1.54x
base_vs_FHA_4core.dat
Base 18 41 33.9 7.06
FHA 16.6 13.07 30.7 7.4 1.47x
base_vs_FHA_8core.dat
Base 27.7 34.3 28.3 9.6
FHA 28.3 11.45 25.3 9.6 1.34x
I want to have each bar in the histogram labeled with the corresponding value and the value of the last column on the top of the second histogram in each pair. How can I achieve this?
Can I merge all the 4 files and achieve the same goal?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以合并一个文件中的所有4个文件。我建议使用两条空行的分离,因为这样,您可以通过
index
轻松地解决(sub)Datablocks,请检查help Index
。对于标签,您可以制作双循环,一个用于(子)数据锁,一个用于列。您必须总结列(检查
help sum
)才能计算标签的y位(即直方图元素的中心)。标签的X位置对于第一个数据集很特别(因为只有列列),因此可以考虑(i*3+$ 0-(i == 0))
, IEi == 0
如果我等于0,则返回1,否则将返回1。您可能想在终端设置大型字体大小,而不是多次设置它,例如:
设置术语pngcairo字体“,17”
。在下面找到最小化的示例,作为进一步优化的起点。
脚本:
结果:
You can merge all 4 files in one file. I would recommend a separation with two empty lines, because with this, you can easily address the (sub)datablocks via
index
, checkhelp index
.For the labels you can make a double loop, one for the (sub)datablocks and one for the columns. You have to sum up the columns (check
help sum
) to calculate the y-position of the label (i.e. center of the histogram element). The x-position of the labels is special for the first dataset (since only this has a columnheader), this is taken into account with(i*3+$0-(i==0))
, i.e.i==0
will return 1 if i equals 0, and 0 otherwise.Instead of setting a large fontsize many times you might want to set it in the terminal, e.g. something like:
set term pngcairo font ",17"
.Find below a minimized example as a starting point for further optimization.
Script:
Result: