Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

x-axis times being cut off #107

donjohnson opened this Issue Apr 25, 2012 · 11 comments


None yet
5 participants

Behavior seen on opentsdb 1.0.0 using both gnuplot 4.2 patchlevel 2 and 4.6 p0:

Basically, the times on the x axis (10:00, 10:30, 11:00) are being cut off by gnuplot and being shown as 0:00, 0:30, 1:00, making it hard to read.

To fix it, I added the line set bmargin 3.5 to my current script as found in the cache directory, re-ran it on the server, and looked at the png output, which had the correct bottom margin.

Could we have handling to ensure the bmargin is correct?


tsuna commented Apr 25, 2012

I know there was a bug in Gnuplot 4.2 that was causing it to clip off the first character of the labels on the X axis, but AFAIK this bug has been fixed in subsequent releases. I don't have the problem with Gnuplot 4.4 p3. I'm surprised that you're running into the issue with 4.6 p0 though.

I wasn't aware of the bmargin trick. If that helps work around the bug, then yeah we can add it.

Here's the script I used:

[root@ip tsd2]# cat don_ed46ba3a.gnuplot 
set term png small size 904,519
set xdata time
set timefmt "%s"
set xtic rotate
set bmargin 3.5
set output "/tmp/tsd2/ed46ba3a.png"
set xrange ["1335341400":"1335361637"]
set format x "%H:%M"
set grid
set style data linespoints
set yrange [0:]
set y2range [0:]
unset key
set y2tics border
plot  "/tmp/tsd2/ed46ba3a_0.dat" using 1:2 title "http.num_requests{host=lb3}", \
 "/tmp/tsd2/ed46ba3a_1.dat" using 1:2 title "proc.loadavg.5min{host=lb3}" axis x1y2

Another possible fix would be to send a "hint" to the margin calculation by setting an xlabel of " " (one space), instead of an undefined label.

Also, a decent workaround for current installations is to move the key/legend box to the bottom center position.

@adrien-mogenet adrien-mogenet added a commit to adrien-mogenet/opentsdb that referenced this issue Sep 24, 2012

@adrien-mogenet adrien-mogenet Fixes #107 Added empty xlabel a4a4605

Still seeing this problem with the latest checkout and gnuplot 4.6.


tsuna commented Nov 24, 2012

I will try to repro with Gnuplot 4.6 and will report back.

I have the same problem (x axis cut off) with gnuplot 4.6 patchlevel 1 and OpenTSDB 1.1.0 on OS X 10.7 Server.

It'd be nice to be able to set the X-axis label manually. I'd like it to read something like "Timestamp (America/Los_Angeles)". I end up scratching my head when I'm giving slides at a conference: now where was I when I made that plot ... ?


tsuna commented Feb 4, 2013

I tried using bmargin 3.5, however this doesn't work because it hardcodes the exact size of the bottom margin, and varying sizes are needed depending on the xformat used.

I tried the idea suggested by @donjohnson and implemented by @adrien-mogenet to add an empty xlabel, however the tics are still clipped for me in Gnuplot 2.6.

I'm not sure what to do that's not fugly and requires TSD to detect what version of Gnuplot is used and work around it. FWIW this bug in Gnuplot 2.6 was fixed in this commit.

If you guys can find a fix/workaround that works reliably, that would be awesome. But so far it looks like we don't have anything solid. The best thing I could think of is to parse the xlabel to count how many characters it can contain (for instance by knowing that %H expands to 2 characters, etc) and then setting the bmargin to be this number of characters. Really ugly but I think this could work.

Pull request #165 just lets those of us proxying PNG requests deal with the issue upstream by setting bmargin explicitly. (I'd still enjoy xlabel options in the web UI but wanted to keep this simple!)

MacPorts has gnuplot 4.6, so I imagine this bug affects most of the (lazy, like me) people installing on OS X. Not sure how many of us there are, though.


tsuna commented Feb 17, 2013

This issue has become really obnoxious – I have the problem too on my Mac, and I use Gnuplot from HomeBrew. I wish we could find a workaround that doesn't require manually adjusting an extra query string parameter based on what version of Gnuplot you have and how much spacing needs to be added :(


isavin commented Feb 18, 2013

Is dropping the rotation of the x-axis labels an option (maybe don't default to rotation as it seems safer and offer it as an option)? That seems to be the cause of this clipping.

I think when rotation is used gnuplot will always use (number_of_lines_in_label + 1) * char_height as the height as set here:

It looks like the value is supposed to be updated here:
using the length of the longest label computed here:
but this branch is never executed because the projection is set to a negative value for vertical text here:

Flipping the sign on L914 seems to do the trick for the simple rotate used in the OpenTSDB scripts but strange things happen if you use "rotate by X" and I'm not at all sure how that sign fits into the rest of the picture.

@tsuna tsuna closed this in b874fe5 Mar 8, 2013

@johann8384 johann8384 added a commit to johann8384/opentsdb that referenced this issue Jun 4, 2013

@isavin @johann8384 isavin + johann8384 Use a 'xtics rotate right' workaround for x-axis label being clipped.
This closes #107.

Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment