Gnuplot xticlabels with multiple lines

if I add xticlabel which uses 3 lines of gnuplot cuts in the middle of the second line. Is there any method for using xticlabels with multiple lines?

This is my data file:

"[17h30,19h00] 25" 1 "[03h30,10h00] 21" 1 "[03h00,12h00] 26" 2 "[18h00,19h30] 27" 3 "[20h30,22h00] 25" 4 "[13h00,14h30] 25" 4 "[19h30,21h30] 25" 5 "[14h30,16h00] 25" 5 "[16h30,18h00] 25" 5 "[09h30,15h00] 25" 9 

And this is my gnuplot code:

 set terminal postscript eps color set output '| epstopdf --filter --outfile=hist.pdf' set auto x set yrange [0:10] set style histogram clustered set boxwidth 0.95 relative set style fill transparent solid 0.5 noborder plot 'hist.dat' using 2:xticlabels(1) with boxes lc rgb'blue90' notitle 

Finally, this is the created graph:

enter image description here

+6
source share
2 answers

Potential issue 1: overlapping xtics

You have several options to help fix your xtic problem.

1) Turn xtics

 set xtics rotate by -45 

This will force the xtics to print at an angle from top left to bottom right.

2) Change the font size

 set xtics font ",4" 

You can make the font size tiny but unreadable.

3) add a gap between the stripes of the chart

 set style histogram gap 4 

4) Modify the data file

If you have control over the data file, you can try inserting some newlines in xtic labels, for example.

 "17h30\n19h00\n25" 1 

Potential issue 2: words too long at all

I'm not quite sure about your question, but you may run into this problem . Gnuplot has a built-in limit on the number of characters in the label, which is set to 50 in older versions of gnuplot and 200 more recently. The post I'm linked to includes a workaround, which is to compile a version of gnuplot with the increased constant MAX_ID_LEN .

+14
source

I had a similar problem, but in my case the labels are taken from two columns (stringcolumn (1) and a numeric column (2)), and the y-data is in the 3rd column.

I split the labels into two using the new line "\ n"

 using 2:3:xticlabels(stringcolumn(1) . "\n\n" . stringcolumn(2)) 

Basically inside xticlabels () you can give any string expression, for example I also needed a number formatting, for which I used the following expression instead of stringcolumn (2):

 gprintf('%1.0t*10^{%S}',column(2)) 

hope this helps

+3
source

All Articles