gnuplot

Tweaking text y axis whitespace in Gnuplot


I'm trying to display a graph that looks like this: gnuplot output It is mostly doing what I want, a label on the y axis and a second label on the box. The box represents a duration of the thing that is described on the y label.

The problem is that the autolayout leaves too much whitespace on the left when the y label lengths aren't close (or maybe just always when it is long, it's just more noticable.) How can I get the label tighter?

Sample script:

set terminal png size 1024,480 background "white"
set output 'timing.png'
set timefmt "%m/%d"
set xdata time
set title "Timeline of Boxes"
set yrange [] 
set timefmt "%m/%d/%Y"
set xrange ["1/01/2019":"10/31/2024"]
set format x "%m/%y"

set ytics nomirror
set grid x y
unset key
set border 3

timeformat = "%m/%d/%Y"
T(N) = timecolumn(N,timeformat)
set datafile separator comma

plot "test1.csv" using (T(3)) : ($5) : (T(3)) : (T(4)) : ($5-0.5) : ($5+0.5) : ($5) : ytic(1) with boxxyerror, \
     "test1.csv" using ((T(3)+T(4))/2):($5) : ($2) with labels center

with data

#first,second,start,end,sequence
fourth y label,fourth box label,12/16/2021,10/30/2024,4
third y label,third box label,6/1/2020,12/15/2021,3
this y label is quite long actually,second box label,1/1/2020,6/1/2020,2
first y label,first box label,6/1/2019,12/30/2019,1

I've done trying to play with the size of the image, and manual adjustments can make it less noticable, but it would be nice to be able to focus on the axis label whitespace.


Solution

  • A quick (and dirty) answer would be: play with lmargin (check help margin), i.e. add a line

    set lmargin 28    # or another suitable value
    

    The drawback is that you have to manually find a suitable value which can be tedious to adjust. It depends on the font and the fontsize. I am (currently) not aware of a solution which works automatically for all fonts and fontsizes.