# Align ylabels of grouped plots at a common line

I use the groupplots library of pgfplots to stack several plots above each other. The y tick label of the two plots have different width as the y axes of the plots are in different scales. As long as I don't set \pgfplotsset{compat=1.6}, pgfplots does not consider the y tick label's width at all and prints the ylabel right across the tick labels. When I activate the compat=1.6 option, the size of the tick labels is considered when placing the label, but in this case (cf. MWE below), the ylabels are placed relative to the tick labels of the concerning plot and therefore the labels of the two plots have different distance to the border of the whole plot group.

Is there a simple command to align the ylabels at a common vertical line instead of aligning each of them relative to its respective plot?

\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=1.6}

\begin{document}
\begin{tikzpicture}
\begin{groupplot}
[group style={group size = 1 by 2}]
\nextgroupplot[ylabel = Text]
\nextgroupplot[ylabel=Text]
\end{groupplot}
\end{tikzpicture}
\end{document}


-
So you want the label to automatically placed so that it accommodates the largest ticklabels, right? Or do you merely want to manually set the spacing? – Jake Oct 5 '12 at 20:16
I would prefer to have this computed automatically. As the left borders of the plots are all aligned, one would just have to compute and/or store the width of the widest y tick label and apply it to all other plots. My hope was that there was already some option in pgfplots itself which toggles this and which I just haven't recognized yet. – Benedikt Bauer Oct 5 '12 at 21:24
At the moment, this option isn't available, because the plots in a groupplots environment are processed sequentially, so the ticklabels of one plot can't influence the label position of an earlier one. – Jake Oct 5 '12 at 21:28

You can redefine the every axis y label style by increasing the xshift value as required.

\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=1.6,
ylabsh/.style={every axis y label/.style={at={(0,0.5)}, xshift=#1, rotate=90}}}

\begin{document}
\begin{tikzpicture}
\begin{groupplot}
[group style={group size = 1 by 2}, ylabsh=-5em]
\nextgroupplot[ylabel = Text]
\nextgroupplot[ylabel=Text]

I would suggest using ylabel absolute, every axis y label/.append style={yshift=1.5em} instead of manually setting all the relevant options. – Jake Oct 5 '12 at 20:35