Adrien
Adrien

Reputation: 55

Gnuplot 4.6 xtics label disappear

I decided to migrate to the latest version of gnuplot from 4.4 to 4.6 I am having issue with the x label disappearing with version 4.6 but being there with version 4.4.

here is a stripped down version of my script.

set key outside
set title "MY TITLE"
set timefmt "%m/%d/%Y-%H:%M:%S"
set format x "%m/%d %H:%M"
set xdata time
set ylabel "Y LABEL"
set xlabel "Time"
set grid
set xtics rotate by 90 offset 0,-5
set terminal pngcairo size 1000,500 font ",9"
set xtics font ",8.0"
set ytics font ",8.0"
set output 'test.png'
plot '-' using 1:2 with linespoints ti "legend"
01/01/2013-00:15 186557
01/01/2013-01:15 254654
01/01/2013-04:00 180146
01/01/2013-06:15 191059
e
set key inside

I've identified the issue to this line

set xtics rotate by 90 offset 0,-5

Because my label is too long the offset makes it go away

if you remove the offset to

set xtics rotate by 90

Not the label show but in the middle of the chart.

Version 4.4 used to compress the chart to leave room for the label.

I guess my knowledge to gnuplot is limited. Anyone has an idea?

thanks

Upvotes: 3

Views: 4047

Answers (1)

mgilson
mgilson

Reputation: 309929

UPDATED ANSWER, courtesy of Ethan Merritt

A better way to do this is to change the justification of the labels to being right justified (rather than the default centered).

set xtics rotate by 90 right

This correctly calculates the margin without needing to hardcode a margin size


The label placement here seems a little flaky to me. I think there might be a bug which I'll probably report. One workaround is to explicitly set the location of the "x-axis" via:

set bmargin at screen 0.2

The reason it seems flakey is because with set bmargin at screen 0.2, the xtic labels clearly extend higher than the position of the xlabel. However, if you comment that line out, all of a sudden they don't extend higher than the position of the xlabel.

Here are the plots with and without that line:

enter image description here

enter image description here

Perhaps cairo/pango cut out labels where any portion of the label extends past the visible "canvas" area?

As a side note, the plot also seems to be roughly correct if I use the postscript terminal...

Upvotes: 3

Related Questions