I want to place the xlabel for a plot on the same baseline the xticklabels. To do that I changed the xlabel style/at key to (ticklabel cs: 1), the rightmost position of the ticklabel coordinate system. However, the label is not on the same baseline, but has a y-offset compared to the tick labels. Note that, I applied an x-shift, to overlay the character 'm' with the tick-label '1' so that the offset can be easily seen.





    xlabel = {m},
    xlabel style = {
      at = { (ticklabel cs: 1) },
      anchor = south,
      xshift = -15pt,
      %yshift = -0.2pt,
    \addplot coordinates { (0,1) (1,0) };


Since I can only post two links, I won't show an picture of the compiled pdf. Instead I will show zoomed in pictures of the axis label overlaid on the tick label. You can easily see there is an offset between the baseline of the tick label and the axis label:

Zoomed in picture showing x label and tick label do not have the same baseline.

If I apply a y-offset manually via the x label style (commented-out shift in the MWE), I can align the baselines of the tick labels and the axis label:

x label and tick label aligned manually.

However, the required y-shift changes with the selected font and various other plot settings. How can I reliably vertically align the axis label with the tick labels?

Thank you in advance for your time and suggestions.

  • That is not enough shift. If I select another font, it is totally off.
    – bev
    Sep 21, 2015 at 15:32

1 Answer 1


I think I can answer my question. This question, or rather the answer got me thinking that 'm' is way smaller than '1' and thus I need \vphantom to align them properly. This was not the case, since both characters do not extend beyond the baseline and are anchored south. However, when applying the \vphantom-command to the style/font-key did not work, I also enabled draw, line width = 1pt to both label styles and everything was aligned properly. After a bit of testing I now think that xlabel and tick label have different line widths for their nodes and that is why they are not vertically aligned. Setting both line widths to 0 aligns everything properly. \vphantom might be needed if something extends below the baseline, like 'g', for example.

Edit: Testing another font, I found I need both: setting the line width and applying \vphantom.

  • Simply kill the outer sep value as in xlabel style = { at = { (ticklabel cs: 1) }, anchor = south, xshift = -15pt, outer sep=0pt, } Sep 21, 2015 at 15:27
  • Doesn't work. I've tried outer sep = 0pt for x label style only as well as together with x tick label style.
    – bev
    Sep 21, 2015 at 15:37
  • Saying simply "doesn't work" is useless. In your example code it works. Sep 21, 2015 at 16:13
  • You are correct. I was doubting myself for a while there. Simply adding \usepackage{unicode-math} suffices to break the outer sep = 0pt-solution (the 'm' is set too low). I assumed simply loading the package did not change anything (after all the font is the same). Not sure why or how this breaks things.
    – bev
    Sep 21, 2015 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.