Gnuplot histogram: how to put values ​​on top of bars

I have the following data:

1   3215
2   321
...
31_60   59
60+   32

I would like to generate a histogram with gnuplot and put the bar value on it.

Here is the gnuplot command I was trying to create a histogram:

set style data histogram
set xtics rotate
plot 'file.dat' using 2:xtic(1)

Can someone tell me how to add values ​​on top of the generated bars?

I found the following bar chart related to the link ( http://gnuplot-tricks.blogspot.com/2009/10/more-on-histograms.html ), but did not understand what it was doing.

+5
source share
3 answers

With this as an example of a Data.dat data file:

1 10
2 20
3 15
4 16
5 19
6 5

You can run this script to display the fields and the corresponding value of this window above it:

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

, u 1: ($ 2 + 0,5): ($ 2), 0.5 , .

+4

using 0 xtic().

plot 'file.dat' using 2:xtic(1) with histogram, '' using 0:2:2 with labels
+12

, data.dat

"Method 1"              99.63               9.13                
"Method 2"              97.35               10.85               
"Method 3"              97.16               13.76                        
"Method 4"              95.16               15.56

gnuplot:

reset

postscript eps 3.5.2.62 'Helvetica, 20' lw 2

'StackOverflow.eps'

set style fill solid 1.00

1

yrange [0: 120]

xtics norangelimit font ", 8"

set ytics norangelimit font ", 8"

xlabel "X-Axis" font "Helvetica, 10"

set ylabel "Y-Axis" font "Helvetica, 10"

", 8"

-8

xoffset = 0,17

= 0,03 -

plot 'data.dat' 2: xtic (1) " 1", 'u 3 " 2", "u 0: 2: 2 "Helvetica, 10" offset -0.9,0.5 title "", '' u 0: 3: 3 font "Helvetica, 10" offset 0.9.0.5 title ""

+1

All Articles