Reputation: 345
I have a clustered histogram which looks like this:
What I would like is some kind of border (like xgrid but between clusters, not at cluster middle).
How can I achieve this?
My histogram is build with this:
set encoding iso_8859_1
set terminal postscript enhanced color
set grid ytics
set style data histogram
set style histogram cluster gap 2
set style fill solid border rgb "black"
set auto x
set xtics rotate by -45
set xrange [0:10]
plot 'data.gnu' using 2:xtic(1), \
'' using 3:xtic(1), \
'' using 4:xtic(1), \
'' using 5:xtic(1), \
'' using 6:xtic(1)
Upvotes: 0
Views: 386
Reputation: 26068
My hope was that you could do something with mxtics
, but I had no success. So then, probably the easiest way is to manually draw the lines. Note that the xtic
is not centered to the histogram if you have 5 bars (or odd number) per group. Shift your borders accordingly.
Code:
### (manual) borders between clustered histogram
reset session
$Data <<EOD
One -1 -2 3 4 5
Two -2 -3 4 5 6
Three -3 -4 5 6 7
Four -4 -5 6 7 8
EOD
set grid ytics
set style data histogram
set style histogram cluster gap 2
set style fill solid border rgb "black"
set xtics rotate by -45
set xrange [-0.5:3.7]
set xtics
unset key
do for [i=1:3] {
set arrow i from i-0.4, graph 0 to i-0.4, graph 1 nohead
}
plot $Data using 2:xtic(1), \
'' using 3:xtic(1), \
'' using 4:xtic(1), \
'' using 5:xtic(1), \
'' using 6:xtic(1)
### end of code
Result:
Upvotes: 2