if I add a xticlabel that uses 3 lines gnuplot cuts at the middle of the second line. Is there any method to have xticlabels with several 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 graph produced:
You have a few options to help fix the xtic problem.
set xtics rotate by -45
This will set the xtics to print at an angle from top-left to bottom-right.
set xtics font ",4"
You could make the font size tiny but unreadable.
set style histogram gap 4
If you have control over the data file, you could try inserting some newlines into the xtic labels, e.g.
"17h30\n19h00\n25" 1
I'm not quite sure from your question, but you may be running into this issue. Gnuplot has a built-in limit for the number of characters in a label, which is set to 50 in older versions of gnuplot and is 200 more recently. The post I linked to includes a workaround, which is to compile a version of gnuplot with an increased MAX_ID_LEN
constant.
I had a similar issue, but in my case the labels where taken from two columns (a stringcolumn(1) and a numeric column(2)), while y-data in 3-rd column.
I split the labels in two using newline "\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 some numeric formatting for which i used instead of stringcolumn(2) the following expression:
gprintf('%1.0t*10^{%S}',column(2))
hope it helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With