I would like to have the y axis labels of all plots in my document above the y axis line. Usually that is above origin but sometimes I have to move the line out of the way. What I am looking for is a method to tie axis line and axis label together, so that they move as if they were one.


The pgfplots manual (chapter 4.9.10 Moving Axis Lines) states that axis y line shift allows to shift the axis line together with all its descriptions, but it does not seem to. The axis line moves but the label (which I consider a description of the axis line) stays in place. Even with ylabel shift the label does not move.

Quick fix

As a substitute I currently move the axis line to the far left and align the label north west. This is not really what I want but I can live with it.

  every axis/.style={
    axis lines={center},               %%% axes at origin by default
    every axis x label/.style={
      at=(current axis.right of origin),
    every axis y label/.style={
      at=(current axis.above origin),   %%% y axis label above origin by default
    axis y line shift={0.5}, %%% attempt: moves axis line (but not the label)
    ylabel shift={0.5},      %%% attempt: has no effect
    % axis y line={left},                          %%% quick fix
    % ylabel style={at=(current axis.north west)}, %%% quick fix
    \addplot table {
      -1 -1
       1  1

The following image shows the output of the code above. The y label did not move with the y axis line. It is above the origin although it should have moved with the line.

label does not move with axis line

The next image shows the result of the quick fix. Label '==y==' is above axis line.

axis line far left

  • I do have trouble understanding what you are asking. Can you show the current output and add the intended outout? But maybe it's just me. May 31, 2021 at 2:00
  • Sorry for the delay. I've edited my post to make it clearer.
    – user234416
    May 31, 2021 at 6:50
  • Will every axis y label/.style={at=(yticklabel* cs:1), ... work in all cases? May 31, 2021 at 18:55
  • @Torbjørn T. Yes, I think it does. Post it and I will accept your answer.
    – user234416
    May 31, 2021 at 19:19

1 Answer 1


You might be able to use

every axis y label/.style={
   at=(yticklabel* cs:1),

to position the axis label. The yticklabel* cs coordinate is described in section 4.9.1 Placement of axis descriptions of the pgfplots manual. (page 244-45 of the manual for version 1.18.1).

Your Answer

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