user669212
user669212

Reputation: 145

increase the spacing between xtic in clustered bar graph (histogram)

Sorry if this looks like simple question (probably) but I searched around to get some solution with no avail.

I have plot a bar graph as shown (attached) here. My problem is to adjust the spacing between label for each xtic which overlap to one another. If you notice the bar graph I attached here, at the x-axis, the "Third label" and "Fourth label long" overlap to each other. Is there anyway to control the spacing so that the labels are not overlap? Additionally, I need the legends (ring1, ring2 and ring12) to be in italics. Since I am using "terminal pngcairo", is there way to do it in italics?

set terminal pngcairo size 550,350 enhanced dash
set output "xplot_ACF_ring1-ring2-head-plots2.png"

set macro
labelFONT="font 'arial,22'"
scaleFONT="font 'arial,12'"
scaleFONT2="font 'helvetica,13'"
keyFONT="font 'arial,18'"
########################################################################################

set ylabel "Time in (ns)"           @labelFONT
set ytic                    @scaleFONT 
set xtic scale 0                @scaleFONT
set size 1.0, 1.0

########################################################################################
ring1 = "#ff0000"; ring2 = "#7FFF00"; ring12 = "#0000FF"
set auto x
set yrange [65:90]
set style data histogram
set style histogram cluster gap 1.5
set style fill solid 1.0 border -1
set boxwidth 0.9 relative
plot 'mal-cel-iso-bcm-ring1-ring2-head-bar-plot2.dat' using 2:xtic(1) ti col fc rgb ring1 ,\
     '' u 3 ti col fc rgb ring2 ,\
     '' u 4 ti col fc rgb ring12

The data for the above script is

Title         "ring1"   "ring2"     "ring12"
"First label"     70        76      77
"Second label"    68        71      69
"Third label"     76        72      68
"Fourth label long"   75        76      77

Below is the plot I get after executing the script. enter image description here

The re-edition of this post start here:

I would like to add error bar in this plot. The sample data is below:

Title   "ring1"         "ring2"         "ring12"
""      77.295326   2.2 74.829245   3.2 78.238016   2.1
""      77.613533   6.2 74.123269   1.5 79.704782   3.6
""      76.589653   2.1 71.704465   2.6 78.736618   4.2
""      75.996256   0.4 73.407460   3.3 77.290057   2.5

The third fifth and seventh columns are actually the error values.

I wish may thanks in advance.

Upvotes: 4

Views: 8463

Answers (3)

user2480972
user2480972

Reputation: 19

Just set the offset:

set offsets <left>, <right>, <top>, <bottom>

you can also find the following commands useful:

unset offsets
show offsets

remember that offsets can be constant or an expression

also remember that offsets are ignored in splots.

Upvotes: 0

choff
choff

Reputation: 31

Another way to get around the problem would be to rotate the labels using:

set xtics rotate out

Or if you want to specify the rotation:

set xtics rotate by -45

Upvotes: 3

Christoph
Christoph

Reputation: 48430

There isn't an explicit option to prevent overlapping of labels.

In your example it is enough to decrease the white spacing to the left and right plot border a bit with

set offset -0.3,-0.3,0,0

which gives you with version 4.6.3:

enter image description here

Other options are e.g.

  • Increase the canvas size (set terminal ... size ...). Note, that set size doesn't affect the image size, but only the size of the graph.

  • For very long labels you can rotate the text e.g. with set xtic rotate ....

Upvotes: 2

Related Questions