gnuplot histogram:如何将值放在条形图的顶部

pyd*_*dra 6 gnuplot histogram

我有以下数据:

1   3215
2   321
...
31_60   59
60+   32
Run Code Online (Sandbox Code Playgroud)

我想使用gnuplot生成直方图,并将bar的值放在它上面.

这是我尝试创建直方图的gnuplot命令:

set style data histogram
set xtics rotate
plot 'file.dat' using 2:xtic(1)
Run Code Online (Sandbox Code Playgroud)

有人能告诉我如何在生成的条形图上添加值吗?

我发现以下链接相关的直方图(http://gnuplot-tricks.blogspot.com/2009/10/more-on-histograms.html),但没有得到它的确切做法.

小智 13

using 0 适用于xtic().

plot 'file.dat' using 2:xtic(1) with histogram, '' using 0:2:2 with labels
Run Code Online (Sandbox Code Playgroud)


Wol*_*tan 4

将此作为一些示例数据文件Data.dat

1 10
2 20
3 15
4 16
5 19
6 5
Run Code Online (Sandbox Code Playgroud)

您可以运行此脚本来显示框及其上方该框的相应值:

set key off
plot 'Data.dat' with boxes fill pattern 1, '' u 1:($2 + 0.5):($2) with labels
Run Code Online (Sandbox Code Playgroud)

请注意u 1:($2 + 0.5):($2),其中0.5指定该值高于框的程度。