Hi Everyone,
I am using Gnuplot Version 5.4 patchlevel 2 (last modified 2021-06-01) on Linux in a Debian WSL2. I think I found a bug for the placement of the x2label.
When the label has an offset greater than -1 character, it is shifted by something like 2 characters. See the attached images.
I could also reproduce this error with different coordinate systems. I tested with the qt and the pdfcairo terminal.
The example plot I made with:
unset xtics
set x2tics
set x2label 'Test' offset 0, -1
plot sin(x) axis x1y2
I hope this is enough to find the bug or that it was not reported previously.
It's complicated. The program tries to juggle placement of the title, x2label, top graph border and x2tics so that they all fit, possibly taking into account font sizes as well. I think what you are seeing is that for the title and the x2label with offsets >= 0 the program assumes that the text is intended to appear above the top border of the plot, so it may move the top plot border down if it thinks this would be necessary for everything to fit. When the y offsets are negative, however, at some point it assumes the text is intended to go below the top plot border, so it leaves the border at the default position or even moves it up.
I can't rule out a bug somewhere, but if you fix the location of the top border first:
set tmargin at screen 0.85
the program has one fewer thing to juggle when laying out the page. I think if you then play with the y offsets for title and x2label you will see they move smoothly relative to the fixed top border.Ok, this sounds quite reasonable. However, I tried the same as above with a fixed topmargin, but there is still the same jump between an offset of -1.0 and -1.1 characters.
But, switching of the x2tics kinda solves the issue. So it really seems like gnuplot is trying to avoid the label sitting in the region of the tics (which seems to be no problem for the xlabel...).
The reason I found this, was that I wanted to have the label in between the x2tics. Do you think there is a workaround, other than using a label instead of the x2label?