# combining absolute and relative coordinates for axis label

Consider the following MWE

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{
compat=1.12,
stdaxis/.style={
ylabel style={at={(ticklabel cs:1.06)},anchor=west,rotate=270},
}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[stdaxis,ylabel=$f(x)$,xlabel=$x$]
\end{axis}
\end{tikzpicture}
\end{document}


This is exactly what I want. My problem is that when I use the same stdaxis style for another picture with a different height, the y-axis label "f(x)" gets too high or too low. To circumvent this, I would like to use an absolute positioning and change the style to something like ylabel style={at={(ticklabel cs:1.0+5mm)},anchor=west,rotate=270}

How is this possible?

You can achieve this with coordinate calculations using the TikZ library calc (cf. section 13.5 of the PGF/TikZ manual):

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\pgfplotsset{
compat=1.12,
stdaxis/.style={
ylabel style={at={($(ticklabel cs:1.0)+(0mm,5mm)$)},anchor=west,rotate=270},
}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[stdaxis,ylabel=$f(x)$,xlabel=$x$]
\end{axis}
\end{tikzpicture}
\end{document}


• I almost tried this, but my mistake was that I assumed, the second coordinate should be one-dimensional, too (as is the axis coordinate). Thanks! Note: esdd's answer produces exactly the same output – riddleculous Mar 27 '16 at 0:20

Use yshift=5mm after rotate=270:

Code:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{
compat=1.12,
stdaxis/.style={
ylabel style={at={(ticklabel cs:1)},
anchor=west,
rotate=270,
yshift=5mm% <-
},
}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[stdaxis,ylabel=$f(x)$,xlabel=$x$]
\begin{axis}[stdaxis,height=10cm,ylabel=$f(x)$,xlabel=$x$]