Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1147 epslatex tick label misalignment

closed-wont-fix
nobody
Drivers (161)
5
2012-07-17
2012-07-03
mivade
No

I've been experiencing a problem with tick label placement since at least version 4.4 (both Windows and Linux), continuing in 4.6 (only checked with Linux so far). By default, both x and y tick labels are not well centered with the ticks. Explicitly setting the format with `set format '$%g%'` seems to fix the x tick label placement, but the y tick labels are still not correctly centered vertically.

I've attached an example with a workaround I've developed after reading some comments on some other epslatex bugs mentioned here.

Discussion

  • mivade
    mivade
    2012-07-03

    example with workaround

     
    Attachments
  • Ethan Merritt
    Ethan Merritt
    2012-07-04

    Could you please provide the gnuplot script also? Without that the TeX files is not very informative.

     
  • mivade
    mivade
    2012-07-04

    example script

     
    Attachments
  • mivade
    mivade
    2012-07-04

    My mistake. I had intended to upload that but accidentally selected the tex file instead.

     
  • Ethan Merritt
    Ethan Merritt
    2012-07-04

    Hmm. The vertical centering looks correct to me, or at least it looks consistent with other gnuplot terminal types. Could you please also attach output from dvips so I can compare what you get to what I get here?

     
  • mivade
    mivade
    2012-07-04

    Behavior with no format setting

     
    Attachments
  • mivade
    mivade
    2012-07-04

    Behavior with x format setting

     
    Attachments
  • mivade
    mivade
    2012-07-04

    Behavior with x and y format setting

     
    Attachments
  • mivade
    mivade
    2012-07-04

    I've uploaded 3 different outputs for comparison:

    no_workaround.eps: All `set format` commands are commented out. x tick labels are clearly offset to the right. y tick labels are less noticeably offset, but it is easy to see in particular with 0 (I've also loaded the output files in Gimp and added horizontal lines to prove to myself that alignment is off).

    x_workaround.eps: Uncommented the `set format x` command. That seems to fix the problem for the xticks, yticks are of course still offset.

    xy_workaround.eps: Uncommented the `set format y` line. y tick label alignment is now better, but looking closely with Gimp shows me there might be a pixel or two of misalignment (not critical, of course).

     
  • Ethan Merritt
    Ethan Merritt
    2012-07-04

    Horizontal centering:
    gnuplot's default format for tic labels is "% g".
    Notice the space between % and g.
    LaTeX includes the space when centering in text mode, but ignores it in math mode. Your work-around was to force math mode, but equally you could just tell gnuplot that to use format "%g" (no space).

    Vertical centering:
    I think that the issue here is that gnuplot's LaTeX output includes a \strut{} command for every vertically-centered label. This forces the centering to treat the entire height of the character box even if the character glyphs inside it are not full-height. This is clearly correct in the case of arbitrary labels. But arguably it is not ideal if it is known that all labels will contain at least one digit [0-9] and will not contain any glyphs that are taller than a diget (e.g. | or &). At that point it becomes font-dependent as well as content-dependent, so I think the current behaviour is about as good as one can reasonably expect. As you found, you can manually add a vertical offset to allow for the different between glyph height and character box height, but you will have to find the offset empirically to match the font.

     
  • Ethan Merritt
    Ethan Merritt
    2012-07-17

    • status: open --> closed-wont-fix