Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Space between Y axis and bar on gnuplot histogram

I have gnuplot script like this:

set term pos eps
set style data histogram
set style histogram clustered gap 1
set grid y
set boxwidth 0.8 absolute
set style fill transparent solid 0.8 noborder
#set key outside right top vertical Left

#component stuff
set output 'eps/component.eps'
set title "Component in interesting Issues"
set xlabel "Components"
set xtics nomirror rotate by -270
plot 'dat/!component' using 2:xtic(1) t "Count" lc rgbcolor "blue" lt 1

and data:

Cmp count
AM    167
NM    90
RM    83
JT    53
TT    51
RED   32
MAP   29
COMM  3
SX    6
HS    68

and this is my output:

output

I see my graph has long spaces between the Y axis and the first bar. How can I spread the bars out evenly?

like image 686
indi60 Avatar asked Dec 30 '25 12:12

indi60


1 Answers

gnuplot gets confused by the first line in your data file, which is supposed to be the header. Just skip this line with every ::1 and the autoscaling is fine:

plot 'dat/!component' using 2:xtic(1) every ::1 t "Count" lc rgbcolor "blue" lt 1

Result with 4.6.4:

enter image description here

In general you don't need to use histograms for this kind of data, the plotting style with boxes also works fine.

like image 77
Christoph Avatar answered Jan 01 '26 08:01

Christoph



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!